Skip to main content

Chat completion

Chat completion by Reigent.

  • URL: /v1/chat/completions

  • Method: POST

  • Headers:

    KeyValue
    AuthorizationBearer rei-agent-secret-token
  • Request:


    model string Optional

    Default: Agent's Configured Model

    Allowed values:

    • openai/gpt-4.1-mini
    • gpt-image-1
    • x-ai/grok-3-beta
    • google/gemini-2.5-flash

    messages array (min length: 1) Required

    Show message structure

    Each message object contains:

    role string Required
    The role of the message author.
    Allowed values: "system", "user", "assistant", "tool"

    content string or array Required
    The contents of the message. Can be:

    • Simple text string
    • Array of content parts (for multimodal inputs)
    Show content parts structure

    Each content part object contains:

    type string Required
    The type of content part.
    Allowed values: "text", "image_url", "file"

    text string Conditional
    Text content (required when type is "text")

    image_url object Conditional
    Image URL details (required when type is "image_url")
    Contains:

    • url string Required
      The URL of the image

    file object Conditional
    File details (required when type is "file")
    Contains:

    • filename string Required
      The name of the file

    • file_data string Required
      The buffer content of the file

    name string Optional
    An optional name for the participant

    tool_call_id string Optional
    Required when role is "tool"

    tool_calls array Optional
    Tool calls made by the assistant


    temperature number Optional

    Range: 0 to 2 Default: 1


    max_tokens integer Optional

    Minimum: 1


    top_p number Optional

    Range: 0 to 1


    n integer Optional

    Minimum: 1


    seed number Optional

    Range: 0 to 2^53-1


    stream boolean Optional


    stop string or array[string] Optional


    presence_penalty number Optional

    Range: -2.0 to 2.0


    frequency_penalty number Optional

    Range: -2.0 to 2.0


    logit_bias object Optional

    Key format: Token IDs as string numbers Value range: -100 to 100


    logprobs boolean Optional


    top_logprobs number Optional


    user string Optional


    response_format object Optional

    • type string
      • Allowed values: "text", "json_object"

    tools array Optional
    A list of tools the model may call

    Show tool structure

    Each tool object contains:

    type string Required
    Must be: "function"

    function object Required
    The function definition

    function.name string Required
    The name of the function

    function.parameters object Required
    The parameters the function accepts


    tool_choice string or object Optional
    Controls which tool is called
    Allowed string values: "none", "auto"
    Or specify a tool with:

    {
    "type": "function",
    "function": {
    "name": "tool_name"
    }
    }

  • Sample Request
  1. Type: Text
Show sample
{
"messages": [
{
"role": "user",
"content": "Hello, can you help me with my research?"
}
],
"tools": [
{
"type": "function",
"function": {
"name": "get_weather",
"description": "Get current temperature of given location",
"parameters": {
"type": "object",
"properties": {
"location": {
"type": "string",
"description": "City and country (e.g. Paris, France)"
}
},
"required": ["location"],
"additionalProperties": false
},
"strict": true
}
}
]
};
  1. Type: Image (in URL)
Show sample
{
"messages": [
{
"role": "user",
"content": [
{
"type": "text",
"text": "Hello, can you help me with my research?"
},
{
"type": "image_url",
"image_url": {
"url": "https://test.png"
}
},
]
}
],
"tools": []
};
  1. Type: Image (in Base64)
Show sample
{
"messages": [
{
"role": "user",
"content": [
{
"type": "text",
"text": "Hello, can you help me with my research?"
},
{
"type": "image_url",
"image_url": {
"url": "data:image/png;base64,iV..."
}
},
]
}
],
"tools": []
};
  1. Type: Docs (PDF)
Show sample
{
"messages": [
{
"role": "user",
"content": [
{
"type": "text",
"text": "Hello, what's inside the PDF?"
},
{
"type": "file",
"file": {
"filename": "Sample File Name",
"file_data": "data:application/pdf;base64,JVBERi0xLjMNCiXi48/....",
}
}
]
}
],
"tools": []
};

  • Response:
  1. Without Tools
Show sample
{
"choices": [
{
"index": 0,
"message": {
"content": "Hello! How can I assist you today?",
"role": "assistant"
}
}
]
}
  1. With Tools
Show sample
{
"choices": [
{
"index": 0,
"message": {
"content": "",
"role": "assistant",
"tool_calls": [
{
"id": "call_zSIBPi4QKxjkpAewfi5YbTnI",
"type": "function",
"function": {
"name": "get_weather",
"arguments": "{\"location\":\"Paris, France\"}"
}
}
]
}
}
]
}

  • Error
Response CodeReason
400Validation Error
401Unauthorized
404Agent not found