← all repositories
openai/openai-go

OpenAI's official Go SDK types the untypeable REST API

It wraps OpenAI's REST API in Go-friendly types so you don't have to hand-roll HTTP clients or wrestle raw JSON unions.

★3.5k stars Go Language Models
openai-go
Not currently ranked — collecting fresh signals.
star history

What it does

This is OpenAI’s official Go client for its REST API. It covers the newer Responses API—streaming, tool calling, conversation state, and structured outputs—while keeping the older Chat Completions API around indefinitely. You get request builders, response parsing, and authentication handling without writing your own HTTP glue.

The interesting bit

The library treats OpenAI’s polymorphic JSON as a Go typing problem rather than a documentation problem. It uses Go 1.24’s omitzero semantics to distinguish missing fields from zero values, and models API unions as structs where only one Of-prefixed field can be set. The result is compiler-checked types for a JSON schema that happily accepts almost anything.

Key highlights

  • First-class Responses API support with streaming, tool calling, and conversation management
  • Chat Completions API remains available and supported indefinitely
  • JSON unions represented as structs with Of-prefixed variant fields
  • Optional fields wrapped in param.Opt[T] with omitzero semantics to avoid accidental zero-value serialization
  • Escape hatches like SetExtraFields and param.Override[T] when the typed surface isn’t enough

Caveats

  • The latest release contains small breaking changes; check the changelog before upgrading
  • Requires Go 1.22 or newer

Verdict

Use it if you want official, typed access to OpenAI’s newest APIs from Go. Skip it if you’re already satisfied with a lighter community client or don’t need Responses API features.

Frequently asked

What is openai/openai-go?
It wraps OpenAI's REST API in Go-friendly types so you don't have to hand-roll HTTP clients or wrestle raw JSON unions.
Is openai-go open source?
Yes — openai/openai-go is open source, released under the Apache-2.0 license.
What language is openai-go written in?
openai/openai-go is primarily written in Go.
How popular is openai-go?
openai/openai-go has 3.5k stars on GitHub.
Where can I find openai-go?
openai/openai-go is on GitHub at https://github.com/openai/openai-go.

heatdrop uses Google Analytics to see which pages get read — nothing else. Your call. How we handle data.