Chat completion
Chat completion by Reigent.
-
URL:
/v1/chat/completions
-
Method:
POST
-
Headers:
Key Value Authorization Bearer rei-agent-secret-token -
Request:
model
string
OptionalDefault: 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) RequiredShow message structure
Each message object contains:
role
string
Required
The role of the message author.
Allowed values:"system"
,"user"
,"assistant"
,"tool"
content
string
orarray
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 participanttool_call_id
string
Optional
Required when role is"tool"
tool_calls
array
Optional
Tool calls made by the assistant
temperature
number
OptionalRange: 0 to 2 Default: 1
max_tokens
integer
OptionalMinimum: 1
top_p
number
OptionalRange: 0 to 1
n
integer
OptionalMinimum: 1
seed
number
OptionalRange: 0 to 2^53-1
stream
boolean
Optional
stop
string
orarray[string]
Optional
presence_penalty
number
OptionalRange: -2.0 to 2.0
frequency_penalty
number
OptionalRange: -2.0 to 2.0
logit_bias
object
OptionalKey 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"
- Allowed values:
tools
array
Optional
A list of tools the model may callShow tool structure
Each tool object contains:
type
string
Required
Must be:"function"
function
object
Required
The function definitionfunction.name
string
Required
The name of the functionfunction.parameters
object
Required
The parameters the function accepts
tool_choice
string
orobject
Optional
Controls which tool is called
Allowed string values:"none"
,"auto"
Or specify a tool with:{
"type": "function",
"function": {
"name": "tool_name"
}
}
- Sample Request
- 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
}
}
]
};
- 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": []
};
- 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": []
};
- 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:
- Without Tools
Show sample
{
"choices": [
{
"index": 0,
"message": {
"content": "Hello! How can I assist you today?",
"role": "assistant"
}
}
]
}
- 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 Code | Reason |
---|---|
400 | Validation Error |
401 | Unauthorized |
404 | Agent not found |