How sashabaranov/go-openai works
Go OpenAI is an unofficial Go SDK for calling OpenAI-compatible APIs. The principal workflow is an application constructing a configured client, invoking an API operation with typed input, and receiving a decoded result or stream. Separate surfaces cover Responses, Chat Completions, and the documented embeddings, images, audio, moderation, files, fine-tuning, batches, vector stores, and Assistants capabilities. Shared client transport builds and sends HTTP requests; sampled source confirms this boundary. Some capability-to-transport links reflect the documented client surface because their implementations were not sampled.
Main entry points: client.go Client · response.go Responses API · chat.go Chat Completions · completion.go Completions
Components 22
Client transport
- Client
client.go - Request builder
internal/request_builder.go - Multipart builder
internal/form_builder.go
Text generation
- Responses API
response.go - Response streaming
response_stream.go - Chat Completions
chat.go - Completions
completion.go
API services
- Embeddings
embeddings.go - Images
image.go - Audio
audio.go - Speech
speech.go - Moderation
moderation.go - Files
files.go - Fine-tuning
fine_tunes.go - Batches
batch.go - Vector stores
vector_store.go - Models
models.go
Assistants API
- Assistants
assistant.go - Threads and messages
thread.go - Runs and steps
run.go
Other components
- Go application
- OpenAI API
Connections 37
- Go application → Client: configures
- Go application → Responses API: requests
- Go application → Chat Completions: requests
- Go application → Completions: requests
- Go application → Embeddings: requests
- Go application → Images: requests
- Go application → Audio: requests
- Go application → Speech: requests
- Go application → Moderation: requests
- Go application → Files: requests
- Go application → Fine-tuning: requests
- Go application → Batches: requests
- Go application → Vector stores: requests
- Go application → Models: requests
- Go application → Assistants: requests
- Go application → Threads and messages: requests
- Go application → Runs and steps: requests
- Responses API → Client: sends requests
- Response streaming → Client: opens stream
- Chat Completions → Client: sends requests
- Completions → Client: sends requests
- Embeddings → Client: sends requests
- Images → Client: sends requests
- Audio → Client: sends requests
- Speech → Client: sends requests
- Moderation → Client: sends requests
- Files → Client: sends requests
- Fine-tuning → Client: sends requests
- Batches → Client: sends requests
- Vector stores → Client: sends requests
- Models → Client: sends requests
- Assistants → Client: sends requests
- Threads and messages → Client: sends requests
- Runs and steps → Client: sends requests
- Client → Request builder: builds request
- Client → Multipart builder: builds multipart
- Client → OpenAI API: sends HTTP