OpenAI Go

The official Go library for the OpenAI API, covering Responses, Chat Completions, Realtime, Assistants, and more with generated, type-safe bindings.

SDK
Go
vv3.54.0
3,439stars
Apache License 2.0

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
87/100Excellent
Development Activity96
Maintenance100
Community68
Maturity44
Momentum40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
84/100Excellent
Architecture85
Code Quality92
Innovation78
Learning Curve80

openai-go is OpenAI’s officially maintained Go client, generated directly from OpenAI’s OpenAPI specification by Stainless (branded internally as Castiron). It gives Go applications typed access to the full surface of the OpenAI platform: the Responses API, the legacy-but-still-supported Chat Completions API, Realtime, Assistants (beta), Conversations, Embeddings, Fine-tuning, Batches, Vector Stores, Moderations, Files/Uploads, Images, Audio, Webhooks, and Admin endpoints.

The library leans on Go 1.24+ encoding/json omitzero semantics to distinguish “not set” from a real zero value in request params, using param.Opt[T] wrappers and generated union types (e.g. ResponseNewParamsInputUnion) instead of loosely-typed interface{} payloads. It ships first-class support for the Amazon Bedrock and Azure OpenAI-compatible endpoints, workload-identity (mTLS/X.509) authentication, and webhook signature verification via client.Webhooks.Unwrap().

Because the package lives at major version 3, its Go module path is versioned as github.com/openai/openai-go/v3 per Go modules convention; SDK v3.45.0+ requires Go 1.25, with v3.44.0 pinned as the last release supporting Go 1.22-1.24.

What You Get

  • A generated Client with one service field per API resource (client.Responses, client.Chat.Completions, client.Embeddings, client.FineTuning, client.VectorStores, client.Batches, client.Admin, client.Realtime, client.Conversations, client.Webhooks, etc.)
  • Type-safe request params using param.Opt[T] for optional fields and generated union types for polymorphic inputs (e.g. string vs. structured input to the Responses API)
  • Built-in streaming support (client.Responses.NewStreaming, chat completion streaming) with a stream accumulator for reconstructing full responses from deltas
  • Webhook signature verification (client.Webhooks.Unwrap()) that parses and authenticates OpenAI webhook payloads in one call
  • Native support for Amazon Bedrock and Azure OpenAI in Azure AI Foundry as alternate backends, plus workload-identity (mTLS/X.509) authentication for enterprise deployments
  • Automatic environment-variable configuration (OPENAI_API_KEY, OPENAI_ADMIN_KEY, OPENAI_ORG_ID, OPENAI_PROJECT_ID, OPENAI_WEBHOOK_SECRET, OPENAI_BASE_URL) via option.RequestOptions

Common Use Cases

  • Generating text or structured JSON output from GPT models via the Responses API in a Go backend service
  • Building a streaming chat interface that consumes token-by-token deltas from Responses.NewStreaming or Chat.Completions.NewStreaming
  • Implementing tool/function calling where the model requests external data and the Go app resolves it and continues the conversation
  • Receiving and verifying OpenAI webhook events (e.g. fine-tuning job completion) in an HTTP handler with client.Webhooks.Unwrap()
  • Routing OpenAI-compatible requests through Amazon Bedrock or Azure OpenAI instead of OpenAI’s own endpoint for compliance or data-residency reasons

Under The Hood

Architecture The root Client struct in client.go composes one service field per API resource (Responses, Chat, Embeddings, FineTuning, VectorStores, Batches, Webhooks, Realtime, Conversations, Admin, and more), each backed by its own generated file or subpackage (responses/, realtime/, conversations/, webhooks/, bedrock/, azure/, auth/). Requests flow through a shared internal/requestconfig layer and an option.RequestOption pipeline that composes API key, organization, project, base URL, and retry/middleware behavior before dispatch. Backend selection (direct OpenAI, Amazon Bedrock, or Azure OpenAI in Azure AI Foundry) is handled by swapping in the bedrock or azure subpackage’s client options rather than branching application code, keeping the resource-service API identical across backends. Streaming responses are handled by a dedicated stream/accumulator layer (streamaccumulator*.go) that reconstructs a complete response object from server-sent-event deltas.

Tech Stack The module (github.com/openai/openai-go/v3, Go 1.25+) has a deliberately small direct dependency set for a client this large: github.com/tidwall/gjson/sjson for JSON path manipulation, plus Azure/azure-sdk-for-go and aws-sdk-go-v2 subpackages pulled in only for the optional Azure and Bedrock backends. Requests use Go 1.24+ encoding/json omitzero semantics via param.Opt[T] wrappers rather than a third-party validation library. CI (.github/workflows/ci.yml, codeql.yml, go-version-review.yml) runs standard go build/go test/CodeQL, plus custom detect-breaking-changes.yml and Castiron-branded code-generation checks that gate manually-edited generated code.

Code Quality The repo carries 113 _test.go files alongside their corresponding generated source files (one test per resource, e.g. chatcompletion_test.go, responses package tests, streamaccumulator_*_test.go covering lifetime, ownership, reconciliation, and logprob edge cases). Errors are returned as explicit Go error values rather than panics in library code (the README’s own examples panic() only for brevity). Naming is consistent and mechanically generated (resource+action, e.g. adminorganizationprojectuser.go), and a .golangci.yml plus documented GO_CODE_QUALITY_POLICY.md/GO_VERSION_POLICY.md formalize lint rules and the supported Go version window.

What Makes It Unique Unlike many hand-written API clients, this SDK is generated end-to-end from OpenAI’s OpenAPI spec (via the Castiron/Stainless pipeline referenced in file headers and CONTRIBUTING.md), so new API surface area ships automatically rather than through manual client updates. It also uniquely unifies three backends (OpenAI direct, Amazon Bedrock, Azure OpenAI in Azure AI Foundry) and adds enterprise-grade workload-identity (mTLS/X.509) authentication and strict webhook-signature verification with a documented 1 MiB payload-size defense-in-depth recommendation, both unusual for a generated client library.

Used by 10 apps in this directory

TypeScript
53%
MIT

Anarlog

Note Taking · AI Assistants · Productivity

9,192

Anarlog is an open-source, local-first AI meeting notetaker that records, transcribes, and summarizes meetings entirely on your device — no cloud lock-in, no mandatory account, and every note saved as a plain markdown file you own forever.

View details
86
Repo Health
77
Technical
69
Dependency
Built with
TypeScript53%
Rust36%
Updated today
Go
75%
AGPL 3.0

Coder

Devops · Developer Tools · Code Editors

14,299

Self-hosted cloud development environments and AI coding agents — defined in Terraform, connected via WireGuard, automatically shut down when idle.

View details
93
Repo Health
90
Technical
69
Dependency
Built with
Go75%
TypeScript23%
Updated today
Go
98%
Other

Crush

Developer Tools · AI Code Assistants · AI Assistants

27,798

Your terminal coding companion — wire up any LLM with LSP intelligence, MCP extensibility, and a skills system that learns your workflow.

View details
87
Repo Health
86
Technical
69
Dependency
Built with
Go98%
Updated today
TypeScript
49%
AGPL 3.0

Grafana

Monitoring · Analytics

76,498

The open-source observability platform that unifies metrics, logs, and traces from any data source into dynamic, queryable dashboards.

View details
95
Repo Health
91
Technical
65
Dependency
Built with
TypeScript49%
Go45%
Updated today
Go
53%
MIT

memos

Note Taking

62,642

Open-source, self-hosted note-taking built for quick capture — Markdown-native, lightweight, and fully yours.

View details
91
Repo Health
78
Technical
66
Dependency
Built with
Go53%
TypeScript46%
Updated today
Go
56%
Other

Multica

AI Assistants · AI Development

48,263

Turn coding agents into real teammates — assign issues, track progress, and compound reusable skills across a vendor-neutral, self-hosted platform.

View details
86
Repo Health
83
Technical
70
Dependency
Built with
Go56%
TypeScript39%
Updated today
Go
74%
Other

Notifuse

Marketing

2,089

Open-source, self-hosted alternative to Mailchimp, Brevo, and Klaviyo — send newsletters and transactional emails without per-email pricing or vendor lock-in.

View details
83
Repo Health
80
Technical
66
Dependency
Built with
Go74%
TypeScript23%
Updated yesterday
Go
70%
Apache 2.0

open-code-review

Developer Tools · Devops

21,645

The AI code review agent born at Alibaba's scale — combining deterministic engineering with LLM intelligence for precise, token-efficient reviews.

View details
81
Repo Health
83
Technical
81
Dependency
Built with
Go70%
TypeScript13%
JavaScript11%
Updated 2 days ago
Go
39%
Apache 2.0

Rill

Analytics · Data Engineering

2,853

The fastest BI tool for humans and agents — define metrics, models, and dashboards as code and query them instantly on ClickHouse or DuckDB.

View details
87
Repo Health
88
Technical
66
Dependency
Built with
Go39%
TypeScript37%
Svelte22%
Updated 2 days ago

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search