🌐
GitHub
github.com › openai › openai-go
GitHub - openai/openai-go: The official Go library for the OpenAI API
package main import ( "context" "fmt" "github.com/openai/openai-go/v3" "github.com/openai/openai-go/v3/option" "github.com/openai/openai-go/v3/shared" ) func main() { client := openai.NewClient( option.WithAPIKey("My API Key"), // defaults to os.LookupEnv("OPENAI_API_KEY") ) chatCompletion, err := client.Chat.Completions.New(context.TODO(), openai.ChatCompletionNewParams{ Messages: []openai.ChatCompletionMessageParamUnion{ openai.UserMessage("Say this is a test"), }, Model: openai.ChatModelGPT5_2, }) if err != nil { panic(err.Error()) } println(chatCompletion.Choices[0].Message.Content) }
Starred by 2.8K users
Forked by 250 users
Languages   Go
🌐
GitHub
github.com › sashabaranov › go-openai
GitHub - sashabaranov/go-openai: OpenAI ChatGPT, GPT-5, GPT-Image-1, Whisper API clients for Go
This library provides unofficial Go clients for OpenAI API.
Starred by 10.5K users
Forked by 1.7K users
Languages   Go
Discussions

Using the OpenAI Responses API in Go
Thank you for pointing the way. The Go SDK is such a pain with all these nested union type parameters, and it's hard to just glance at the Python/JS examples (which are straightforward) and translate them to Go. More on reddit.com
🌐 r/golang
3
19
May 12, 2025
OpenAI Agents Python SDK, reimplemented in Go
NLP Odyssey is legit. Your other ML packages for Go are top tier. I’ve used them in some previous projects with success. Definitely keeping an eye out on this one. More on reddit.com
🌐 r/golang
20
53
June 16, 2025
Any safe way to have a client-side app talk to OpenAI API directly?
I’m building an app that talks to the OpenAI API. It’s working nicely and am now looking at how to roll it out for release. However since our app talks to openAI directly without our own server as an intermediary - it seems we need to store the API key on the client side (at least after ... More on community.openai.com
🌐 community.openai.com
1
0
November 13, 2024
[deleted by user]
This is a pretty well covered library, that also supports the recent 3.5-turbo models as well as chat. https://github.com/sashabaranov/go-gpt3 More on reddit.com
🌐 r/golang
11
79
July 23, 2022
🌐
OpenAI
platform.openai.com › docs › libraries
Libraries | OpenAI API
October 6, 2025 - 1 2 3 4 5 6 7 8 9 import OpenAI from "openai"; const client = new OpenAI(); const response = await client.responses.create({ model: "gpt-5.2", input: "Write a one-sentence bedtime story about a unicorn." }); console.log(response.output_text);
🌐
Medium
medium.com › @soumitsr › reinventing-the-wheel-openai-apis-through-go-part-1-c88dcf39c201
Reinventing The Wheel: OpenAI APIs Through Go — Part 1 | by Soumit Salman Rahman | Medium
February 4, 2024 - Reinventing The Wheel: OpenAI APIs Through Go — Part 1 Dude! There is a WHOLE bank of libraries for that in python. What conceivable reason do you have to do this in Go? Cause I feel like it! Deal …
🌐
Microsoft Learn
learn.microsoft.com › en-us › azure › developer › go › azure-ai-for-go-developers
Develop Go apps that use Azure AI services - Go on Azure | Microsoft Learn
October 1, 2025 - These models can be easily adapted to your specific task including but not limited to content generation, summarization, image understanding, semantic search, and natural language to code translation. Users can access the service through REST APIs, Azure OpenAI SDK for Go, or via the Azure AI Foundry portal.
🌐
Medium
medium.com › codex › lets-make-a-gpt-wrapper-http-server-with-golang-and-openai-e8ef5adc8f8a
Let’s make a GPT-4 HTTP-Server with GOLANG (And OPENAI) | by Tomascdmota | CodeX | Medium
December 3, 2024 - package main import ( "net/http" "context" "time" "log" "sync" "github.com/gin-gonic/gin" openai "github.com/sashabaranov/go-openai" ) const ( API_KEY = "" // We'll go back to this later batchWindowMs = 100 // add whatever value you want, this will wait for 100ms ) var systemMessage = openai.ChatCompletionMessage{ Role: "system", Content: `You are a helpful assistant. Transform the query into a boolean logic using boolean operators (AND, OR, NOT...), don't show comments.`, } type RequestBuffer struct { client *openai.Client batchWindow time.Duration // How long the buffer will wait before send
Find elsewhere
🌐
Go Packages
pkg.go.dev › github.com › Azure › azure-sdk-for-go › sdk › ai › azopenai
azopenai package - github.com/Azure/azure-sdk-for-go/sdk/ai/azopenai - Go Packages
November 10, 2025 - Example_audioTranscription demonstrates how to transcribe speech to text using Azure OpenAI's Whisper model. This example shows how to: - Create an Azure OpenAI client with token credentials - Read an audio file and send it to the API - Convert spoken language to written text using the Whisper model - Process the transcription response
🌐
Better Programming
betterprogramming.pub › chatgpt-golang-a7bd524e7563
Consume OpenAI (ChatGPT) With Golang
September 11, 2023 - type Client struct { apiKey string Organization string } // NewClient creates a new client func NewClient(apiKey string, organization string) *Client { return &Client{ apiKey: apiKey, Organization: organization, } } // Post makes a post request func (c *Client) Post(url string, input any) (response []byte, err error) { response = make([]byte, 0) rJson, err := json.Marshal(input) if err != nil { return response, err } resp, err := c.Call(http.MethodPost, url, bytes.NewReader(rJson)) if err != nil { return response, err } defer resp.Body.Close() response, err = io.ReadAll(resp.Body) return respo
🌐
DEV Community
dev.to › widlestudio › unlocking-ai-potential-integrating-openai-api-into-golang-microservices-fia
Unlocking AI Potential: Integrating OpenAI API into GoLang Microservices - DEV Community
August 4, 2023 - Creating a new GoLang project for the microservice integration. Setting up dependencies for API communication and JSON handling. ... Signing up for an OpenAI account and obtaining API access credentials.
🌐
Google AI
ai.google.dev › gemini api › openai compatibility
OpenAI compatibility | Gemini API | Google AI for Developers
November 18, 2025 - Chicago, IL", }, "unit": {"type": "string", "enum": ["celsius", "fahrenheit"]}, }, "required": ["location"], }, } } ] messages = [{"role": "user", "content": "What's the weather like in Chicago today?"}] response = client.chat.completions.create( model="gemini-2.5-flash", messages=messages, tools=tools, tool_choice="auto" ) print(response) import OpenAI from "openai"; const openai = new OpenAI({ apiKey: "GEMINI_API_KEY", baseURL: "https://generativelanguage.googleapis.com/v1beta/openai/" }); async function main() { const messages = [{"role": "user", "content": "What's the weather like in Chicago today?"}]; const tools = [ { "type": "function", "function": { "name": "get_weather", "description": "Get the weather in a given location", "parameters": { "type": "object", "properties": { "location": { "type": "string", "description": "The city and state, e.g.
🌐
Rollbar
rollbar.com › home › how to use the chatgpt api with golang
How to Use the ChatGPT API with Golang | Rollbar
August 18, 2023 - Before getting in the weeds with the steps though, here is the complete code block to call ChatGPT within Golang and get a response. package main import ( "encoding/json" "fmt" "log" "github.com/go-resty/resty/v2" ) const ( apiEndpoint = "https://api.openai.com/v1/chat/completions" ) func main() { // Use your API KEY here apiKey := "YOUR API KEY HERE" client := resty.New() response, err := client.R().
🌐
Chris Sotherden
chris.sotherden.io › openai-responses-api-using-go
Using the OpenAI Responses API in Go (Golang) – Intro Guide
May 12, 2025 - Learn to use the OpenAI Responses API with Go. Covers state, tools, file search, structured output, with the official Go SDK (openai-go)
🌐
Relia Software
reliasoftware.com › blog › openai-golang-ai-chatbot-development
How to Build a Golang AI Chatbot with OpenAI? Hands-on Guide
July 4, 2025 - This blog guides to build a Golang AI chatbot using OpenAI, including features like chat completion, conversation context management, and streaming responses.
Price   $$$$$
Address   629 Nguyen Kiem, Ward 9, Phu Nhuan District, 700000, Ho Chi Minh
🌐
Reddit
reddit.com › r/golang › openai agents python sdk, reimplemented in go
r/golang on Reddit: OpenAI Agents Python SDK, reimplemented in Go
June 16, 2025 -

Hey, I've been exploring agentic AI frameworks and found OpenAI's Python Agents SDK to be the most balanced in terms of simplicity and features. To better understand it and to make it usable in the Go ecosystem, I co-started a Go reimplementation.

It's an independent effort and still a work in progress, but already quite usable :)

As we continue refactoring, we'll work on better package separation and building patterns, balancing Go idioms with user-friendliness. Feedback is welcome: whether it’s about design choices, missing pieces, or more idiomatic ways to structure things in Go.

Thanks!

Matteo