Skip to content

Chat Completions

Short description: Text completion API, compatible with traditional completions format (e.g., gpt-3.5-turbo-instruct series). This page includes request parameters, examples, and response examples.


Overview

  • Method: POST
  • Path: /v1/completions
  • Content-Type: application/json

Authentication

  • Use standard header authentication: Authorization: Bearer sk-xxx.

Request parameters

ParameterTypeRequiredDescription
modelstringyesModel name, e.g. gpt-3.5-turbo-instruct
prompt / messagesstring or arrayyesInput prompt (this endpoint commonly uses prompt field; if using messages, refer to chat API format)
temperaturenumbernoSampling temperature (0-2), higher -> more random
top_pnumbernoNucleus sampling threshold
max_tokensnumbernoMax generated tokens
nintegernoNumber of candidate completions to return
streambooleannoUse streaming response
presence_penaltynumbernoPresence penalty (-2.0~2.0)
frequency_penaltynumbernoFrequency penalty (-2.0~2.0)
logprobsintegernoReturn probability info for each token
userstringnoEnd-user identifier for abuse monitoring

Examples

curl example

bash
curl -X POST "https://api.gpt.ge/v1/completions" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer sk-xxxx" \
  -d '{
    "model": "gpt-3.5-turbo-instruct",
    "prompt": "The weather is very nice",
    "temperature": 0.7,
    "max_tokens": 100,
    "top_p": 1,
    "frequency_penalty": 0,
    "presence_penalty": 0,
    "logprobs": 1
  }'

JavaScript (fetch) example

javascript
fetch('https://api.gpt.ge/v1/completions', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json', 'Authorization': 'Bearer sk-xxxx' },
  body: JSON.stringify({ model: 'gpt-3.5-turbo-instruct', prompt: 'The weather is very nice', temperature: 0.7, max_tokens: 100, logprobs: 1 })
}).then(r => r.json()).then(console.log)

Python (requests) example

python
import requests

payload = {
  'model': 'gpt-3.5-turbo-instruct',
  'prompt': 'The weather is very nice',
  'temperature': 0.7,
  'max_tokens': 100,
  'logprobs': 1
}

resp = requests.post('https://api.gpt.ge/v1/completions', headers={'Content-Type':'application/json','Authorization':'Bearer sk-xxxx'}, json=payload)
print(resp.json())

Response example (200)

json
{
  "id": "cmpl-A1tJLfyQgj1j2GpvhA6QcMCZKwRtw",
  "object": "text_completion",
  "created": 1725014307,
  "model": "gpt-3.5-turbo-instruct",
  "choices": [
    {
      "text": ", perfect for going out\n\nYes, the weather is very nice today, perfect for a trip.",
      "index": 0,
      "logprobs": {
        "tokens": [",", " perfect", " for", " going", " out", "\n\n", "Yes", ",", " the", " weather", " is", " very", " nice", " today", ",", " perfect", " for", " a", " trip", "."],
        "token_logprobs": [-0.80, -3.95, -0.01, -0.00, -0.09, -0.00, -0.32, -1.13, -0.98, -0.15, -0.25, -0.00, -1.63, -0.29, -0.39]
      },
      "finish_reason": "stop"
    }
  ],
  "usage": { "prompt_tokens": 6, "completion_tokens": 25, "total_tokens": 31 }
}