Skip to main content
POST
/
v1
/
chat
/
completions
Chat Completion
curl --request POST \
  --url https://www.anyfast.ai/v1/chat/completions \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "model": "gemini-2.5-pro",
  "messages": [
    {
      "role": "user",
      "content": "Hello!"
    }
  ],
  "max_tokens": 2,
  "temperature": 1,
  "top_p": 0.5,
  "frequency_penalty": 0,
  "presence_penalty": 0,
  "stream": false,
  "stop": "<string>",
  "n": 1,
  "response_format": {
    "type": "text"
  }
}
'
{
  "id": "chatcmpl-abc123",
  "object": "chat.completion",
  "created": 123,
  "model": "gemini-2.5-pro",
  "choices": [
    {
      "index": 123,
      "message": {
        "role": "assistant",
        "content": "Hello! How can I help you today?"
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 123,
    "completion_tokens": 123,
    "total_tokens": 123
  }
}

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Body

application/json
model
enum<string>
required

Gemini model ID to use for completion.

Available options:
gemini-3.1-pro-preview,
gemini-3.1-flash-image-preview,
gemini-3.1-flash-lite-preview,
gemini-3-pro-preview,
gemini-3-pro-image-preview,
gemini-3-flash-preview,
gemini-2.5-pro,
gemini-2.5-flash,
gemini-2.5-flash-lite,
gemini-2.0-flash
Example:

"gemini-2.5-pro"

messages
object[]
required

A list of messages comprising the conversation so far.

Minimum array length: 1
Example:
[{ "role": "user", "content": "Hello!" }]
max_tokens
integer

The maximum number of tokens to generate in the chat completion.

Required range: x >= 1
temperature
number
default:1

Sampling temperature between 0 and 2.

Required range: 0 <= x <= 2
Example:

1

top_p
number

Nucleus sampling threshold.

Required range: 0 <= x <= 1
frequency_penalty
number
default:0

Penalizes new tokens based on their existing frequency in the text so far.

Required range: -2 <= x <= 2
presence_penalty
number
default:0

Penalizes new tokens based on whether they appear in the text so far.

Required range: -2 <= x <= 2
stream
boolean
default:false

If true, partial message deltas will be sent as server-sent events.

stop

Sequences where the API will stop generating further tokens.

n
integer
default:1

How many chat completion choices to generate for each input message.

Required range: x >= 1
response_format
object

An object specifying the format that the model must output. Setting to {"type": "json_object"} enables JSON mode.

Response

Completion generated successfully

id
string
required
Example:

"chatcmpl-abc123"

object
string
required
Example:

"chat.completion"

created
integer
required

Unix timestamp of when the completion was created.

model
string
required
Example:

"gemini-2.5-pro"

choices
object[]
required
usage
object