Text Completions
Legacy text completion endpoint.
POST /v1/completions
Traditional text completion endpoint. Given a prompt, the model generates text that continues from where the prompt leaves off. This is the legacy completion format — for conversational AI, prefer using Chat Completions.
Parameters#
| Parameter | Type | Required | Description |
|---|---|---|---|
model | string | Yes | The model ID to use. |
prompt | string/array | Yes | The prompt to generate completions for. |
max_tokens | integer | No | Maximum number of tokens to generate. |
temperature | number | No | Sampling temperature between 0 and 2. |
top_p | number | No | Nucleus sampling parameter. |
n | integer | No | Number of completions to generate. |
stream | boolean | No | If true, response is streamed. |
stop | string/array | No | Sequences where generation stops. |
Example Requests#
cURL#
curl https://ai.pofano.com/v1/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{
"model": "gpt-3.5-turbo-instruct",
"prompt": "Once upon a time in a land far away,",
"max_tokens": 100,
"temperature": 0.8
}'Python#
import requests
response = requests.post(
"https://ai.pofano.com/v1/completions",
headers={
"Authorization": "Bearer YOUR_API_KEY",
"Content-Type": "application/json"
},
json={
"model": "gpt-3.5-turbo-instruct",
"prompt": "Once upon a time in a land far away,",
"max_tokens": 100,
"temperature": 0.8
}
)
print(response.json())JavaScript#
const response = await fetch("https://ai.pofano.com/v1/completions", {
method: "POST",
headers: {
"Authorization": "Bearer YOUR_API_KEY",
"Content-Type": "application/json"
},
body: JSON.stringify({
model: "gpt-3.5-turbo-instruct",
prompt: "Once upon a time in a land far away,",
max_tokens: 100,
temperature: 0.8
})
});
const data = await response.json();
console.log(data);
Pofano