Skip to main content
POST
/
v1
/
chat
/
completions

Authorization

  • Auth Type: Bearer Auth (In: header)
  • Format: Authorization: Bearer <YOUR_API_KEY>
  • Description: Use Bearer <YOUR_API_KEY>. Format: Authorization: Bearer sk-xxxxxx.
  • API Key: where API Key is your AGCloud API KEY

Request Body

Core Parameters

FieldTypeRequiredDefaultDescription
modelstring-The model identifier to use for this request, e.g. gemini-2.5-flash.
messagesarray-An array of message objects representing the conversation history. Messages are processed in order.
>messages.rolestring-The role of the message author. Valid values: system, user, assistant.
>messages.contentstring/array-The content of the message. Can be a simple string or an array of content blocks for multimodal inputs.
>>messages.content.typestring-The type of content block. Supported: text, image_url.
>>messages.content.textstring-The text content. Required when type is text.

Generation Parameters

FieldTypeRequiredDefaultDescription
max_tokensinteger--The maximum number of tokens the model can generate in the response.
temperaturefloat-1.0Controls the randomness of the output. Lower values produce more focused responses, higher values produce more creative outputs. Range in 0.0 - 2.0.
top_pfloat-1.0Nucleus sampling parameter. The model considers tokens with top_p cumulative probability mass. Range in 0.0 - 1.0.
streamboolean-falseIf true, returns a stream of server-sent events (SSE) as the response is generated.
stopstring/array--Up to 4 sequences where the API will stop generating further tokens.
ninteger-1How many chat completion choices to generate for each input message.
presence_penaltyfloat-0Penalizes new tokens based on whether they appear in the text so far. Range in -2.0 - 2.0.
frequency_penaltyfloat-0Penalizes new tokens based on their existing frequency in the text so far. Range in -2.0 - 2.0.

Advanced Parameters

FieldTypeRequiredDefaultDescription
toolsarray<object>--A list of tools the model may call. Use this to provide functions the model can generate JSON inputs for.
tool_choicestring/object-autoControls which tool is called. none: no tool, auto: model decides, required: must call a tool.
userstring--A unique identifier representing your end-user, which can help to monitor and detect abuse.

Tools Structure

FieldTypeRequiredDefaultDescription
typestring--Utility types, currently generally functions
functionobject--Function definition
>function.namestring--The function name
>function.descriptionstring--Function usage description
>function.parametersobject--Function parameter definition
>>function.parameters.locationstring-City name
>>function.parameters.unitstring--Can be celsius fahrenheit