Skip to content

bukhavtsov/golang-server-with-chat-gpt-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

How to integrate Golang Service with Chat GPT API.

Intro

In this tutorial we're going to create a Golang service that communicates with Chat GPT API.

Considerations

For implementing solution we need to have:

  1. API Key to Chat GPT API and at the moment Chat GPT doesn't provide free trial, so you'll have to setup your Open API account and pay X per token. But for a pet project it's quite fair price in my opinion.
  2. Golang installed.

What we'll try to develop?

Essentially to get familiar with Chat GPT API we'll try to create a smart dictionary. As an input we'll send a http request with a lexical item and in response we get the meaning, examples of usages. Architecture will consist of 2 components:

  • Backend - Golang application with Echo web framework.
  • Chat GPT API that Open AI provides.

architecture

How to run

  1. Specify env variables CHAT_GPT_API_URL and CHAT_GPT_API_KEY
  2. Start the server
go run ./cmd/main.go
  1. Test with curl
curl localhost:8080/v1/translations/feasible

Response example:

{
   "lexicalItem":"feasible",
   "meaning":"possible to do easily or conveniently",
   "example":"Given our limited resources, it may not be feasible to launch a new product at this time."
}

Other materials:

About

How to integrate Golang Service with Chat GPT API.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages