Go gateway beta quickstart
Go developers can use the official sashabaranov/go-openai SDK against VerticalAPI by setting BaseURL and adding the provider key as a custom header. Suitable for high-throughput backends.
From beta docs to a verified test
Read the gateway beta documentation
Confirm current access, supported providers, compatibility and limits.
Prepare scoped credentials
Follow your provider's current key-handling guidance and avoid production credentials during evaluation.
Install the Go SDK
go get github.com/sashabaranov/go-openaiRun the example below
Use the documented base URL and required headers, then verify the returned shape for this beta path.
Validate the result
Check response shape, model behavior, limits and total cost against the provider before production.
Go — first call
package main
import (
"context"
"fmt"
"net/http"
openai "github.com/sashabaranov/go-openai"
)
func main() {
cfg := openai.DefaultConfig("vapi_...")
cfg.BaseURL = "https://api.verticalapi.com/v1"
cfg.HTTPClient = &http.Client{
Transport: &headerTransport{
base: http.DefaultTransport,
providerKey: "sk-...",
},
}
client := openai.NewClientWithConfig(cfg)
resp, _ := client.CreateChatCompletion(context.Background(), openai.ChatCompletionRequest{
Model: "gpt-4o",
Messages: []openai.ChatCompletionMessage{
{Role: "user", Content: "Hello, world"},
},
})
fmt.Println(resp.Choices[0].Message.Content)
}
type headerTransport struct{ base http.RoundTripper; providerKey string }
func (h *headerTransport) RoundTrip(r *http.Request) (*http.Response, error) {
r.Header.Set("X-Provider-Key", h.providerKey)
return h.base.RoundTrip(r)
}Model IDs and provider support can drift. Check the source-dated model directory and current beta documentation before changing the model or provider header.
Common errors and fixes
Where to go from here
Pick a model in the source-dated directory. Compare two in the decision comparisons. Review the benchmark evidence policy before trusting performance claims.