Add streaming AI chat responses to a Go application using OpenAI GPT models
Generate images from text prompts in a Go program using DALL-E or GPT Image
Transcribe or translate audio files in Go using the Whisper speech-to-text API
Create text embeddings in Go for use in search or similarity features
Requires a paid OpenAI API key to call the API.
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.
← sashabaranov on gitmyhub — every repo by this author, as a profile.
Verify against the repo before relying on details.