🧿
Making requests
1
curl https://api.eye-ai.com/v1/completions \
2
-H "Content-Type: application/json" \
3
-H "Authorization: Bearer YOUR_API_KEY" \
4
-d '{"model": "text-davinci-003", "prompt": "Say this is a test", "temperature": 0, "max_tokens": 7}'
This request queries the Davinci model to complete the text starting with a prompt of "Say this is a test". The
max_tokens
parameter sets an upper bound on how many tokens the API will return. You should get a response back that resembles the following:1
{
2
"id": "cmpl-GERzeJQ4lvqPk8SkZu4XMIuR",
3
"object": "text_completion",
4
"created": 1586839808,
5
"model": "text-davinci:003",
6
"choices": [
7
{
8
"text": "\n\nThis is indeed a test",
9
"index": 0,
10
"logprobs": null,
11
"finish_reason": "length"
12
}
13
],
14
"usage": {
15
"prompt_tokens": 5,
16
"completion_tokens": 7,
17
"total_tokens": 12
18
}
19
}
Now you've generated your first completion. If you concatenate the prompt and the completion text (which the API will do for you if you set the
echo
parameter to true
), the resulting text is "Say this is a test. This is indeed a test." You can also set the stream
parameter to true
for the API to stream back textLast modified 9mo ago