Function calling and structured output
Function calling and structured output are still text APIs, but availability depends on model capability and route compatibility. Add fallbacks for unsupported models.
Endpoint: POST /v1/chat/completions
Function calling example
curl https://aivrae.com/v1/chat/completions \
-H "Authorization: Bearer YOUR_AIVRAE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "MODEL_NAME",
"messages": [
{ "role": "user", "content": "What is the weather in Shanghai?" }
],
"tools": [
{
"type": "function",
"function": {
"name": "get_weather",
"description": "Get current weather",
"parameters": {
"type": "object",
"properties": {
"city": { "type": "string" }
},
"required": ["city"]
}
}
}
],
"tool_choice": "auto"
}'
JSON output example
curl https://aivrae.com/v1/chat/completions \
-H "Authorization: Bearer YOUR_AIVRAE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "MODEL_NAME",
"response_format": { "type": "json_object" },
"messages": [
{ "role": "system", "content": "Return valid JSON only." },
{ "role": "user", "content": "Generate a JSON object with name and slogan." }
]
}'