SDKv2.0.0
Go SDK
Drop-in OpenAI-compatible client for Go. One BaseURL override and you're routing through Meridian with full observability, rate limiting, and cost controls.
Quickstart
Install go-openai and point the BaseURL at Meridian. Everything else stays the same.
Terminal
go get github.com/sashabaranov/go-openaiUsage
The only change from a standard go-openai setup is the BaseURL field in the client config.
main.go
package main
import (
"context"
"fmt"
"os"
openai "github.com/sashabaranov/go-openai"
)
func main() {
client := openai.NewClientWithConfig(openai.ClientConfig{
BaseURL: "https://api.getnimbus.net/v1",
APIType: openai.APITypeOpenAI,
})
resp, err := client.CreateChatCompletion(
context.Background(),
openai.ChatCompletionRequest{
Model: "gpt-4o",
Messages: []openai.ChatCompletionMessage{
{Role: "user", Content: "Hello from Go!"},
},
},
)
if err != nil {
fmt.Fprintf(os.Stderr, "error: %v\n", err)
os.Exit(1)
}
fmt.Println(resp.Choices[0].Message.Content)
}Streaming
Streaming works identically — set Stream: true and iterate the channel.
main.go
stream, err := client.CreateChatCompletionStream(
ctx,
openai.ChatCompletionRequest{
Model: "gpt-4o",
Stream: true,
Messages: []openai.ChatCompletionMessage{
{Role: "user", Content: "Tell me a short story."},
},
},
)
if err != nil {
panic(err)
}
defer stream.Close()
for {
resp, err := stream.Recv()
if err != nil {
break
}
fmt.Print(resp.Choices[0].Delta.Content)
}Authentication
Meridian uses the standard Authorization: Bearer header. Set your API key via the config or environment variable.
Config field
client := openai.NewClientWithConfig(openai.ClientConfig{
BaseURL: "https://api.getnimbus.net/v1",
APIType: openai.APITypeOpenAI,
APIKey: "nimbus_sk_...",
})Environment variable
export OPENAI_API_KEY="nimbus_sk_..."
# go-openai reads this automaticallySupported Endpoints
Any go-openai method that hits /v1/chat/completions or /v1/embeddings works through Meridian.
CreateChatCompletionSingle-turn chat
CreateChatCompletionStreamStreaming chat
CreateEmbeddingsText embeddings
ListModelsAvailable models