This repository contains a collection of fully working Go examples demonstrating how to use the new OpenAI Responses API with the official openai-go SDK.
Each directory contains a self-contained example that maps to a specific concept covered in the blog post:
Read the full post here:
https://chris.sotherden.io/openai-responses-api-using-go
| Directory | Description |
|---|---|
responses |
Basic single-prompt usage with the Responses API |
responses-file-search |
Uploads files to a vector store and perform semantic search using the file_search tool |
responses-input-file |
Shows how to include input files as part of the prompt context |
responses-state-management |
Demonstrates multi-turn conversation state management using PreviousResponseID |
responses-structured-output |
Uses structured output with JSON Schema to control the response format |
responses-tool-calling |
Shows how to enable and handle tool calling and web search |
- Go 1.18 or higher
- OpenAI API key (set
OPENAI_API_KEYas an environment variable) - An existing Vector Store for the file search example (set
VECTOR_STORE_IDas an environment variable) - Modules initialized via
go mod tidy
Clone this repository:
git clone https://github.com/csotherden/openai-responses-go-examples.git
cd openai-responses-go-examples
go mod tidyRun any individual example:
cd responses-structured-output
go run main.go- OpenAI Responses API Overview
- Official OpenAI Go SDK
- My blog post: Using the OpenAI Responses API with Go
Feel free to open an issue or PR if you’d like to expand or improve the examples!
© 2025 Chris Sotherden