Go SDK for interacting with OpenAI's GPT models
Top 78.4% on sourcepulse
This Go client library provides a convenient way for developers to interact with OpenAI's ChatGPT, GPT-4, and GPT-3 APIs. It simplifies making requests for text completion, chat completions (including streaming), image generation, and document search, enabling seamless integration of powerful AI models into Go applications.
How It Works
The library acts as a direct wrapper around the OpenAI API, abstracting away the complexities of HTTP requests, JSON serialization, and error handling. It utilizes Go's standard library for networking and JSON processing, offering a clean and idiomatic interface for developers. The NewClient
function initializes the client with an API key, and various methods like ChatCompletionStream
, CompletionWithEngine
, and Image
map directly to OpenAI's respective API endpoints.
Quick Start & Requirements
git clone https://github.com/hanyuancheung/gpt-go.git
export API_KEY={YOUR_API_KEY}
then make chatgpt-example
and ./chatgpt
Highlighted Details
Maintenance & Community
gofmt
.Licensing & Compatibility
Limitations & Caveats
The project primarily focuses on wrapping the OpenAI API and does not include higher-level abstractions or state management for complex conversational flows. Users are responsible for managing API keys and understanding OpenAI's usage policies.
2 years ago
Inactive