curl --location 'https://api.inworld.ai/llm/v1alpha/completions:completeChat' \
--header "Authorization: Basic $INWORLD_API_KEY" \
--header 'Content-Type: application/json' \
--data '{
"servingId": {
"modelId": {
"model": "gpt-4o-mini",
"serviceProvider": "SERVICE_PROVIDER_OPENAI"
},
"userId": "user-123"
},
"messages": [
{"role": "MESSAGE_ROLE_USER", "content": "Hello, how are you?"}
],
"textGenerationConfig": {
"maxTokens": 100,
"stream": false
}
}'import os
import requests
url = "https://api.inworld.ai/llm/v1alpha/completions:completeChat"
headers = {
"Authorization": f"Basic {os.getenv('INWORLD_API_KEY')}",
"Content-Type": "application/json"
}
payload = {
"servingId": {
"modelId": {
"model": "gpt-4o-mini",
"serviceProvider": "SERVICE_PROVIDER_OPENAI"
},
"userId": "user-123"
},
"messages": [
{"role": "MESSAGE_ROLE_USER", "content": "Hello, how are you?"}
],
"textGenerationConfig": {
"maxTokens": 100,
"stream": False
}
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())const url = 'https://api.inworld.ai/llm/v1alpha/completions:completeChat';
const response = await fetch(url, {
method: 'POST',
headers: {
'Authorization': `Basic ${process.env.INWORLD_API_KEY}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
servingId: {
modelId: {
model: 'gpt-4o-mini',
serviceProvider: 'SERVICE_PROVIDER_OPENAI',
},
userId: 'user-123',
},
messages: [
{ role: 'MESSAGE_ROLE_USER', content: 'Hello, how are you?' },
],
textGenerationConfig: {
maxTokens: 100,
stream: false,
},
}),
});
const data = await response.json();
console.log(data);{
"result": {
"id": "chatcmpl-D0KDzqXlvlNfWI00Ynj5eRFoI14Dw",
"choices": [
{
"finishReason": "FINISH_REASON_STOP",
"message": {
"content": "Hello! I'm just a program, so I don't have feelings, but I'm here and ready to help you. How can I assist you today?",
"role": "MESSAGE_ROLE_ASSISTANT"
}
}
],
"createTime": "2026-01-21T04:35:15Z",
"model": "gpt-4o-mini",
"usage": {
"completionTokens": 29,
"promptTokens": 13
},
"serviceProvider": "SERVICE_PROVIDER_OPENAI"
}
}{
"code": 123,
"message": "<string>",
"details": [
{
"@type": "<string>"
}
]
}Create chat completion
Generates a response for the given chat conversation.
curl --location 'https://api.inworld.ai/llm/v1alpha/completions:completeChat' \
--header "Authorization: Basic $INWORLD_API_KEY" \
--header 'Content-Type: application/json' \
--data '{
"servingId": {
"modelId": {
"model": "gpt-4o-mini",
"serviceProvider": "SERVICE_PROVIDER_OPENAI"
},
"userId": "user-123"
},
"messages": [
{"role": "MESSAGE_ROLE_USER", "content": "Hello, how are you?"}
],
"textGenerationConfig": {
"maxTokens": 100,
"stream": false
}
}'import os
import requests
url = "https://api.inworld.ai/llm/v1alpha/completions:completeChat"
headers = {
"Authorization": f"Basic {os.getenv('INWORLD_API_KEY')}",
"Content-Type": "application/json"
}
payload = {
"servingId": {
"modelId": {
"model": "gpt-4o-mini",
"serviceProvider": "SERVICE_PROVIDER_OPENAI"
},
"userId": "user-123"
},
"messages": [
{"role": "MESSAGE_ROLE_USER", "content": "Hello, how are you?"}
],
"textGenerationConfig": {
"maxTokens": 100,
"stream": False
}
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())const url = 'https://api.inworld.ai/llm/v1alpha/completions:completeChat';
const response = await fetch(url, {
method: 'POST',
headers: {
'Authorization': `Basic ${process.env.INWORLD_API_KEY}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
servingId: {
modelId: {
model: 'gpt-4o-mini',
serviceProvider: 'SERVICE_PROVIDER_OPENAI',
},
userId: 'user-123',
},
messages: [
{ role: 'MESSAGE_ROLE_USER', content: 'Hello, how are you?' },
],
textGenerationConfig: {
maxTokens: 100,
stream: false,
},
}),
});
const data = await response.json();
console.log(data);{
"result": {
"id": "chatcmpl-D0KDzqXlvlNfWI00Ynj5eRFoI14Dw",
"choices": [
{
"finishReason": "FINISH_REASON_STOP",
"message": {
"content": "Hello! I'm just a program, so I don't have feelings, but I'm here and ready to help you. How can I assist you today?",
"role": "MESSAGE_ROLE_ASSISTANT"
}
}
],
"createTime": "2026-01-21T04:35:15Z",
"model": "gpt-4o-mini",
"usage": {
"completionTokens": 29,
"promptTokens": 13
},
"serviceProvider": "SERVICE_PROVIDER_OPENAI"
}
}{
"code": 123,
"message": "<string>",
"details": [
{
"@type": "<string>"
}
]
}Authorizations
Should follow the format Basic {credentials}. The {credentials} consists of the Base64-encoded string of the API key and the secret in the format key:secret. You can create a key in one command with the Inworld CLI: inworld workspace add-key.
Body
Chat completion request.
Describes the serving ID of the request to select the right model.
Show child attributes
Show child attributes
A list of messages comprising the conversation so far.
Chat message.
- Text Content
- Multi-modal Content
Show child attributes
Show child attributes
A list of tools the model may call. Currently, only functions are supported as a tool. Use this to provide a list of functions the model may generate JSON inputs for. Only supported for OpenAI.
Show child attributes
Show child attributes
Controls which (if any) function is called by the model. Only supported for OpenAI.
Show child attributes
Show child attributes
Configuration for chat completion generation.
Show child attributes
Show child attributes
Format that the model must output..
- RESPONSE_FORMAT_UNSPECIFIED: Response format is not specified. Defaults to "text".
- RESPONSE_FORMAT_TEXT: Text response format.
- RESPONSE_FORMAT_JSON: Only supported when stream = False. JSON response format. This guarantees that the message the model generates is valid JSON. Note that your system prompt must still instruct the model to produce JSON, and to help ensure you don't forget, the API will throw an error if the string JSON does not appear in your system message. Also note that the message content may be partial (i.e. cut off) if finish_reason="length", which indicates the generation exceeded max_tokens or the conversation exceeded the max context length. Only supported for OpenAI.
- RESPONSE_FORMAT_JSON_SCHEMA: JSON schema response format. It enables Structured Outputs which ensures the model will match your supplied JSON schema. Only supported for OpenAI.
RESPONSE_FORMAT_UNSPECIFIED, RESPONSE_FORMAT_TEXT, RESPONSE_FORMAT_JSON, RESPONSE_FORMAT_JSON_SCHEMA Request timeout in seconds. This setting applies only to selected clients and configured by a separate request to Inworld. Make sure to configure these specific requests accordingly, as this timeout will not affect others.
JSON schema configuration. Only supported for OpenAI.
Show child attributes
Show child attributes
Was this page helpful?