whatisgithub

What is go-openai?

sashabaranov/go-openai — explained in plain English

Analysis updated 2026-06-24

10,657GoAudience · developerComplexity · 2/5Setup · easy

In one sentence

A Go library that handles all the details of calling OpenAI's APIs, chat, image generation, speech-to-text, and embeddings, so you can add AI features to a Go program without writing the HTTP plumbing yourself.

Mindmap

mindmap
  root((go-openai))
    What it does
      OpenAI API client
      Go language library
      Community unofficial
    Capabilities
      Chat and streaming
      Image generation
      Speech to text
      Embeddings
    Use Cases
      AI chat in Go apps
      Image from text
      Audio transcription
    Setup
      Go 1.18 required
      API key needed
      Works with alt APIs
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

What do people build with it?

USE CASE 1

Add streaming AI chat responses to a Go application using OpenAI GPT models

USE CASE 2

Generate images from text prompts in a Go program using DALL-E or GPT Image

USE CASE 3

Transcribe or translate audio files in Go using the Whisper speech-to-text API

USE CASE 4

Create text embeddings in Go for use in search or similarity features

What is it built with?

Go

How does it compare?

sashabaranov/go-openaipressly/goosemrs4s/go-cqhttp
Stars10,65710,65610,667
LanguageGoGoGo
Setup difficultyeasyeasyhard
Complexity2/52/53/5
Audiencedeveloperdeveloperdeveloper

Figures from each repo's GitHub metadata at analysis time.

How do you get it running?

Difficulty · easy Time to first run · 30min

Requires a paid OpenAI API key to call the API.

So what is it?

Go-openai is a Go library that makes it straightforward to call OpenAI's APIs from a Go program. OpenAI provides services like ChatGPT for text generation, Whisper for converting speech to text, and DALL-E and GPT Image for generating images from text descriptions. These services are accessible over the internet through an API, meaning a program sends a request and gets a response back. This library handles the details of formatting those requests and parsing the responses, so developers do not have to write that plumbing themselves. The core use case is sending chat messages to a language model and receiving a reply. The library supports both regular request-and-response calls and streaming, where the reply arrives word by word as it is generated, similar to how ChatGPT types out its answers on screen. Both styles are common: streaming is better for showing output to a user in real time, while the standard call is simpler when the result is processed further before being shown. Beyond chat, the library covers several other OpenAI capabilities: generating images from a text prompt using DALL-E 2, DALL-E 3, or the newer GPT Image 1 model, transcribing or translating audio files using the Whisper model, creating text embeddings, which are numerical representations of text used in search and similarity tasks, and fine-tuning models on custom data. The README includes working code examples for most of these. The library requires Go 1.18 or later. It is unofficial, meaning it is a community project not produced or endorsed by OpenAI, though it covers the official OpenAI API surface. Configuration options allow pointing it at compatible alternative APIs, such as self-hosted models that speak the same protocol.

Copy-paste prompts

Prompt 1
Using go-openai, help me write a Go function that sends a user message to GPT-4 and streams the reply token by token to standard output.
Prompt 2
Show me how to use go-openai to transcribe an MP3 file using the Whisper model and print the resulting text in Go.
Prompt 3
Help me configure go-openai to point at a local self-hosted model that uses the OpenAI-compatible API format.
Prompt 4
I want to generate an image from a text prompt using DALL-E 3 in Go, show me the complete go-openai code to do that.
Prompt 5
Help me create text embeddings for a list of strings using go-openai so I can compare their similarity scores.

Frequently asked questions

What is go-openai?

A Go library that handles all the details of calling OpenAI's APIs, chat, image generation, speech-to-text, and embeddings, so you can add AI features to a Go program without writing the HTTP plumbing yourself.

What language is go-openai written in?

Mainly Go. The stack also includes Go.

How hard is go-openai to set up?

Setup difficulty is rated easy, with roughly 30min to a first successful run.

Who is go-openai for?

Mainly developer.

Open on GitHub → Ask about another repo

This repo across BitVibe Labs

Verify against the repo before relying on details.