Skip to content

ctate/go-openai-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

go-openai-api 🧠

This project is a Go-powered API server built with Gin and Go OpenAI that interacts with the OpenAI API, enabling seamless streaming of responses.

Features

  • Fast HTTP server using Gin
  • Streamlined interaction with OpenAI API
  • Real-time streaming of responses

Prerequisites

  • Go (version 1.21.x or higher)
  • An active OpenAI API Key

Getting Started

1. Clone the Repository

git clone https://github.com/ctate/go-openai-api.git
cd go-openai-api

2. Set up Environment Variables

Before running the project, add an .env file with these environment variable:

API_PORT="8080"
OPEN_API_KEY="your_openai_api_key"

3. Run the Server

To start the server:

go run .

By default, the server will start on http://localhost:8080.

Endpoints

  • POST /chat: Streams chat completions from OpenAI API

Usage Example

Here's a quick example using curl to interact with the API:

curl -XPOST --no-buffer http://localhost:8080/chat -H "Content-Type: application/json" -d '{"prompt":"Lorem ipsum"}'

Contributing

Contributions are welcome! Feel free to submit pull requests or create issues for bugs and feature requests.

License

MIT

About

OpenAI streaming powered by Go/Gin

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published