Go SDK
The Go SDK and docs are currently in beta. Report issues on GitHub.
The OpenRouter Go SDK is a type-safe client for building AI applications with access to 400+ language models through a unified API.
Why use the OpenRouter SDK?
Integrating AI models into applications involves handling different provider APIs, managing model-specific requirements, and avoiding common implementation mistakes. The OpenRouter SDK standardizes these integrations with idiomatic Go types, retries, and typed errors.
The SDK provides three core benefits:
Auto-generated from API specifications
The SDK is automatically generated from OpenRouter’s OpenAPI specs and updated with every API change. New models, parameters, and features appear in generated types and docs immediately.
Type-safe by default
Request and response types live under models/components and models/operations. API errors are mapped to typed values under models/sdkerrors.
Streaming and platform APIs
Use the same client for streaming chat completions, embeddings, rerank, TTS, video generation, and platform APIs such as API keys, credits, models, guardrails, and workspaces.
See examples/chat-stream for a runnable streaming chat example.
Installation
For beta releases, pin an explicit version:
Requirements: Go 1.25 or higher
Get your API key from dynamicsinfo.com/settings/keys.
Quick start
See examples/README.md for runnable examples, starting with examples/chat, or the API Reference for the full method list.