Function calling
A function calling occurs when you interact with the Chat API to communicate with a Language Learning Model (LLM). Within the tool array, you have the flexibility to define custom functions. This capability enables the model to dynamically generate and provide function signatures in JSON format, facilitating seamless integration with external tools and applications.
Available models
Model | Release date | Context Length | Description |
---|---|---|---|
solar-1-mini-chat | 2024-06-14 beta | 32768 | A compact LLM offering superior performance to GPT-3.5, with robust multilingual capabilities for both English and Korean, delivering high efficiency in a smaller package. solar-1-mini-chat is alias for our latest Solar Mini model. (Currently solar-1-mini-chat-240612 ) |
Request
POST https://api.upstage.ai/v1/solar/chat/completions
Request body
messages[].tool_calls[].type string Required |
messages[].tool_calls[].function string Required |
messages[].tool_calls[].function.name string Required |
messages[].tool_calls[].function.arguments string Required |
Example
Request
curl --location 'https://api.upstage.ai/v1/solar/chat/completions' \
--header 'Authorization: Bearer UPSTAGE_API_KEY' \
--header 'Content-Type: application/json' \
--data '{
"model": "solar-1-mini-chat",
"messages": [
{
"role": "user",
"content": "How is the weather in San Francisco today?"
}
],
"tools": [
{
"type": "function",
"function": {
"name": "get_current_weather",
"description": "Get the current weather in a given location",
"parameters": {
"type": "object",
"properties": {
"location": {
"type": "string",
"description": "The city and state, e.g. San Francisco, CA"
},
"unit": {
"type": "string",
"enum": ["celsius", "fahrenheit"]
}
},
"required": ["location", "unit"]
}
}
}
]
}'
Response sample
Success - HTTP Status 200 OK
{
"id": "68ca5a6b-7cfa-402d-bba3-4fd7710640df",
"object": "chat.completion",
"created": 1710715081,
"model": "solar-1-mini-chat-240612",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": null,
"tool_calls": [
{
"id": "e7e01748-b53b-4f98-90a7-f330f5cba2af",
"type": "function",
"function": {
"name": "get_current_weather",
"arguments": "{\"location\":\"San Francisco\",\"unit\":\"fahrenheit\"}"
}
},
{
"id": "948f5e4c-09fc-402f-b703-e4ace12b7d48",
"type": "function",
"function": {
"name": "get_current_weather",
"arguments": "{\"location\":\"Seoul\",\"unit\":\"celsius\"}"
}
},
{
"id": "d25d38e0-6a7d-428e-8953-0cd2f5b81969",
"type": "function",
"function": {
"name": "get_current_weather",
"arguments": "{\"location\":\"Paris\",\"unit\":\"celsius\"}"
}
}
]
},
"logprobs": null,
"finish_reason": "tool_calls"
}
],
"usage": {
"prompt_tokens": 567,
"completion_tokens": 177,
"total_tokens": 744
},
"system_fingerprint": null
}