Chat Completions
Short description: Text completion API, compatible with traditional completions format (e.g.,
gpt-3.5-turbo-instructseries). 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
| Parameter | Type | Required | Description |
|---|---|---|---|
| model | string | yes | Model name, e.g. gpt-3.5-turbo-instruct |
| prompt / messages | string or array | yes | Input prompt (this endpoint commonly uses prompt field; if using messages, refer to chat API format) |
| temperature | number | no | Sampling temperature (0-2), higher -> more random |
| top_p | number | no | Nucleus sampling threshold |
| max_tokens | number | no | Max generated tokens |
| n | integer | no | Number of candidate completions to return |
| stream | boolean | no | Use streaming response |
| presence_penalty | number | no | Presence penalty (-2.0~2.0) |
| frequency_penalty | number | no | Frequency penalty (-2.0~2.0) |
| logprobs | integer | no | Return probability info for each token |
| user | string | no | End-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 }
}