A Python library giving one interface for chat, streaming, tool calls, and structured output across AI providers.
openai/openai-go
The official Go client library for the OpenAI REST API, covering Responses, Chat Completions, Realtime and more.
- Stars
- 3,528
- Forks
- 360
- Open issues
- 87
- Last commit
- 22 hours ago
What is it?
openai-go is the official Go library for the OpenAI REST API. It lets Go applications call OpenAI endpoints through typed request and response structs instead of hand-built HTTP calls. The primary entry point is the Responses API, with helpers for generating text, multi-turn conversations, streaming, tool calling and structured outputs. The Chat Completions API is also supported.
The library covers more than text generation. It includes WebSocket connections for the Responses API, typed Realtime and Live connections, pagination helpers for list endpoints, file uploads through io.Reader, and webhook signature verification with payload parsing. Requests use functional options for headers, timeouts and retries, and errors are returned as *openai.Error for programmatic handling.
The module requires Go 1.26 or later, and the README gives pinned versions for older Go toolchains.
Key features
- 01Typed Go structs for Responses and Chat Completions API calls.
- 02Streaming responses and tool (function) calling helpers.
- 03Structured outputs with JSON schema generated from Go types.
- 04WebSocket connections for Responses, plus typed Realtime and Live connections.
- 05Auto-pagination helpers for list endpoints and webhook signature verification.
Use cases
- Adding LLM text generation or chat to a Go backend service.
- Building multi-turn assistants that keep conversation state via response IDs.
- Extracting typed data from model output using JSON schema.
- Receiving and verifying OpenAI webhook events in a Go server.
Quick start
- 1
Install the SDK at a pinned version
go get -u 'github.com/openai/openai-go/v3@v3.96.0' - 2
Set your OpenAI API key in the OPENAI_API_KEY environment variable
- 3
Create a client and call client.Responses.New with the Responses example code from the README
Things to know
- Requires Go 1.26 or later; older toolchains must pin an older SDK release.
- The latest version has small, limited breaking changes, so check the changelog before upgrading.
- Responses WebSockets are unavailable in js/wasm builds.
In collections
Topics
FAQ
- What is openai-go?
- The official Go client library for the OpenAI REST API, covering Responses, Chat Completions, Realtime and more. openai-go is the official Go library for the OpenAI REST API. It lets Go applications call OpenAI endpoints through typed request and response structs instead of hand-built HTTP calls. The primary entry point is the Responses API, with helpers for generating text, multi-turn conversations, streaming, tool calling and structured outputs. The Chat Completions API is also supported.
- Is openai-go free to use? What license does it have?
- openai-go is open source under the Apache-2.0 license. Check the license terms before using it in commercial products.
- Is openai-go still maintained?
- Actively maintained. The last commit to openai-go was on Nov 6, 2026.
- What can I use openai-go for?
- Adding LLM text generation or chat to a Go backend service. Building multi-turn assistants that keep conversation state via response IDs. Extracting typed data from model output using JSON schema. Receiving and verifying OpenAI webhook events in a Go server.
- How do I install openai-go?
- Install the SDK at a pinned version: go get -u 'github.com/openai/openai-go/v3@v3.96.0' Set your OpenAI API key in the OPENAI_API_KEY environment variable Create a client and call client.Responses.New with the Responses example code from the README
- Where can I get openai-go?
- The source code and installation instructions are on GitHub: https://github.com/openai/openai-go
Summary generated by AI from the project's README. GitHub stats refresh daily.
Related projects
Type-safe, provider-agnostic TypeScript SDK for streaming chat, tool calling, agents, and multimodal apps across major LLM providers and UI frameworks.
A Ruby on Rails framework for building AI-powered apps where agents are implemented as controllers with actions and views.
The official Python library for the OpenAI REST API, with sync and async clients and typed request and response models.
An unofficial, zero-dependency Go client for the OpenAI API, covering Responses, Chat Completions, images, audio and more.
Community-maintained Swift package wrapping the OpenAI public API, covering chat, responses, images, audio, embeddings and assistants.