SDKsGo SDK
Go SDK
Use Nemo Router with the official OpenAI Go SDK
Last updated
Nemo Router works with the official openai-go SDK. Set the base URL to https://api.nemorouter.ai/v1 and pass your sk-nemo-... key — guardrails, caching, and rate-limits auto-apply from your org config.
Installation
go get github.com/openai/openai-goSetup
import (
"github.com/openai/openai-go"
"github.com/openai/openai-go/option"
)
client := openai.NewClient(
option.WithAPIKey(os.Getenv("NEMOROUTER_API_KEY")),
option.WithBaseURL("https://api.nemorouter.ai/v1"),
)Chat Completion
package main
import (
"context"
"fmt"
"os"
"github.com/openai/openai-go"
"github.com/openai/openai-go/option"
)
func main() {
client := openai.NewClient(
option.WithAPIKey(os.Getenv("NEMOROUTER_API_KEY")),
option.WithBaseURL("https://api.nemorouter.ai/v1"),
)
response, err := client.Chat.Completions.New(context.Background(),
openai.ChatCompletionNewParams{
Model: "claude-sonnet-4-20250514",
Messages: []openai.ChatCompletionMessageParamUnion{
openai.UserMessage("Hello!"),
},
},
)
if err != nil {
fmt.Printf("Error: %v\n", err)
return
}
fmt.Println(response.Choices[0].Message.Content)
}Per-Request Overrides
The Go SDK does not yet support extra_body fields natively. To pass nemo_* fields per request (guardrails, prompt templates, cache toggle), use a raw HTTP POST and include them in the JSON body:
{
"model": "gpt-4o",
"messages": [{"role": "user", "content": "Summarize Q1 earnings..."}],
"nemo_guardrail_ids": ["uuid1", "uuid2"],
"nemo_prompt_template_id": "your-summarizer-id",
"nemo_prompt_variables": {"language": "Spanish"},
"nemo_cache": false
}Response Headers
Every successful response carries:
x-nemo-request-cost— exact USD spend for this callx-nemo-guardrails-applied— comma-separated guardrail names that ranx-nemo-prompt-version— version of the prompt template applied (if any)
Next Steps
- cURL Examples — Inspect raw request/response shape
- Authentication — API key best practices
- Chat Completions API — Full API reference
Was this page helpful?