curl --request POST \
--url https://api.inworld.ai/llm/v1alpha/completions:completeChat \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"servingId": {
"modelId": {
"model": "<string>",
"serviceProvider": "SERVICE_PROVIDER_UNSPECIFIED"
},
"userId": "<string>",
"sessionId": "<string>"
},
"messages": [
{
"content": "<string>",
"role": "MESSAGE_ROLE_UNSPECIFIED",
"toolCalls": [
{
"id": "<string>",
"functionCall": {
"name": "<string>",
"args": "<string>"
}
}
],
"toolCallId": "<string>",
"name": "<string>",
"textContent": "<string>",
"contentItems": {
"contentItems": [
{
"text": "<string>",
"imageUrl": {
"url": "<string>",
"detail": "<string>"
}
}
]
}
}
],
"tools": [
{
"functionCall": {
"name": "<string>",
"properties": {},
"description": "<string>"
}
}
],
"toolChoice": {
"text": "<string>",
"object": {
"functionCall": {
"name": "<string>"
}
}
},
"textGenerationConfig": {
"frequencyPenalty": 123,
"logitBias": [
{
"tokenId": "<string>",
"biasValue": 123
}
],
"maxTokens": 123,
"n": 123,
"presencePenalty": 123,
"stop": [
"<string>"
],
"stream": true,
"temperature": 123,
"topP": 123,
"repetitionPenalty": 123,
"seed": 123
},
"responseFormat": "RESPONSE_FORMAT_UNSPECIFIED",
"requestTimeout": 123,
"jsonSchema": {
"name": "<string>",
"description": "<string>",
"strict": true,
"schema": {}
}
}
'{
"result": {
"id": "<string>",
"choices": [
{
"finishReason": "FINISH_REASON_UNSPECIFIED",
"index": 123,
"message": {
"content": "<string>",
"toolCalls": [
{
"id": "<string>",
"functionCall": {
"name": "<string>",
"args": "<string>"
}
}
],
"role": "MESSAGE_ROLE_UNSPECIFIED"
}
}
],
"createTime": "2023-11-07T05:31:56Z",
"model": "<string>",
"usage": {
"completionTokens": 123,
"promptTokens": 123,
"estimatedCompletionTokens": 123,
"estimatedPromptTokens": 123
}
},
"error": {
"code": 123,
"message": "<string>",
"details": [
{
"@type": "<string>"
}
]
}
}Generates a response for the given chat conversation.
curl --request POST \
--url https://api.inworld.ai/llm/v1alpha/completions:completeChat \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"servingId": {
"modelId": {
"model": "<string>",
"serviceProvider": "SERVICE_PROVIDER_UNSPECIFIED"
},
"userId": "<string>",
"sessionId": "<string>"
},
"messages": [
{
"content": "<string>",
"role": "MESSAGE_ROLE_UNSPECIFIED",
"toolCalls": [
{
"id": "<string>",
"functionCall": {
"name": "<string>",
"args": "<string>"
}
}
],
"toolCallId": "<string>",
"name": "<string>",
"textContent": "<string>",
"contentItems": {
"contentItems": [
{
"text": "<string>",
"imageUrl": {
"url": "<string>",
"detail": "<string>"
}
}
]
}
}
],
"tools": [
{
"functionCall": {
"name": "<string>",
"properties": {},
"description": "<string>"
}
}
],
"toolChoice": {
"text": "<string>",
"object": {
"functionCall": {
"name": "<string>"
}
}
},
"textGenerationConfig": {
"frequencyPenalty": 123,
"logitBias": [
{
"tokenId": "<string>",
"biasValue": 123
}
],
"maxTokens": 123,
"n": 123,
"presencePenalty": 123,
"stop": [
"<string>"
],
"stream": true,
"temperature": 123,
"topP": 123,
"repetitionPenalty": 123,
"seed": 123
},
"responseFormat": "RESPONSE_FORMAT_UNSPECIFIED",
"requestTimeout": 123,
"jsonSchema": {
"name": "<string>",
"description": "<string>",
"strict": true,
"schema": {}
}
}
'{
"result": {
"id": "<string>",
"choices": [
{
"finishReason": "FINISH_REASON_UNSPECIFIED",
"index": 123,
"message": {
"content": "<string>",
"toolCalls": [
{
"id": "<string>",
"functionCall": {
"name": "<string>",
"args": "<string>"
}
}
],
"role": "MESSAGE_ROLE_UNSPECIFIED"
}
}
],
"createTime": "2023-11-07T05:31:56Z",
"model": "<string>",
"usage": {
"completionTokens": 123,
"promptTokens": 123,
"estimatedCompletionTokens": 123,
"estimatedPromptTokens": 123
}
},
"error": {
"code": 123,
"message": "<string>",
"details": [
{
"@type": "<string>"
}
]
}
}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
Chat completion request.
Describes the serving ID of the request to select the right model.
Show child attributes
Unique identifier of the model being requested.
Show child attributes
Service provider hosting llm and handling completion requests. See Models for additional details and options.
SERVICE_PROVIDER_UNSPECIFIED, SERVICE_PROVIDER_INWORLD, SERVICE_PROVIDER_ANTHROPIC, SERVICE_PROVIDER_OPENAI, SERVICE_PROVIDER_GOOGLE, SERVICE_PROVIDER_MISTRAL, SERVICE_PROVIDER_TENSTORRENT, SERVICE_PROVIDER_FIREWORKS, SERVICE_PROVIDER_GROQ Unique identifier representing end-user.
Unique identifier of the session with multiple completion requests.
A list of messages comprising the conversation so far.
Chat message.
Show child attributes
The content of the message.
The role of the messages author.
MESSAGE_ROLE_UNSPECIFIED, MESSAGE_ROLE_SYSTEM, MESSAGE_ROLE_USER, MESSAGE_ROLE_ASSISTANT, MESSAGE_ROLE_TOOL The tool calls generated by the model, such as function calls. Only supported for OpenAI.
Show child attributes
The ID of the tool call.
The function that the model called.
Show child attributes
The name of the function to call.
The arguments to call the function with, as generated by the model in JSON format. Note that the model does not always generate valid JSON, and may hallucinate parameters not defined by your function schema. Validate the arguments in your code before calling your function.
Tool call that this message is responding to. Only supported for OpenAI.
Provides the model information to differentiate between participants of the same role.
A collection of content items.
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
Function to call.
Show child attributes
The name of the function to be called. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64.
The parameters the functions accepts, described as a JSON Schema object.
A description of what the function does, used by the model to choose when and how to call the function.
Controls which (if any) function is called by the model. Only supported for OpenAI.
Show child attributes
Supported values: "none" means the model will not call a function and instead generates a message. "auto" means the model can pick between generating a message or calling a function.
Configuration for text completion generation.
Show child attributes
Positive values penalize new tokens based on their existing frequency in the text so far, decreasing the model's likelihood to repeat the same line verbatim. Defaults to 0.
Modify the likelihood of specified tokens appearing in the completion. Mathematically, the bias is added to the logits generated by the model prior to sampling. The exact effect will vary per model, but values between -1 and 1 should decrease or increase likelihood of selection; values like -100 or 100 should result in a ban or exclusive selection of the relevant token. Only supported for OpenAI and Google.
Maximum number of output tokens allowed to generate. The total length of input tokens and generated tokens is limited by the model's context length. Defaults to inf.
How many choices to generate for each input message. Defaults to 1.
Positive values penalize new tokens based on whether they appear in the text so far, increasing the model's likelihood to talk about new topics. Defaults to 0.
Up to 4 sequences where the API will stop generating further tokens.
If set, partial message deltas will be sent. Defaults to false.
What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. Defaults to 1.
An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered. Defaults to 1.
Float that penalizes new tokens based on whether they appear in the prompt and the generated text so far. Values > 1 encourage the model to use new tokens, while values < 1 encourage the model to repeat tokens. The value must be strictly positive. Defaults to 1 (no penalty).
Random seed for decoding.
Format that the model must output..
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
The name of the response format. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64.
A description of what the response format is for, used by the model to determine how to respond in the format.
Whether to enable strict schema adherence when generating the output. If set to true, the model will always follow the exact schema defined in the schema field. Only a subset of JSON Schema is supported when strict is true.
The schema for the response format, described as a JSON Schema object.
A successful response.(streaming responses)
Chat completion response.
Show child attributes
A unique identifier for the chat completion. Each chunk has the same ID.
A list of chat completion choices. Can be more than one if n is greater than 1.
Show child attributes
The reason the model stopped generating tokens.
FINISH_REASON_UNSPECIFIED, FINISH_REASON_STOP, FINISH_REASON_LENGTH, FINISH_REASON_CONTENT_FILTER, FINISH_REASON_TOOL_CALL The index of the choice in the list of choices.
Chat completion message.
Show child attributes
The contents of the chunk message.
The tool calls generated by the model, such as function calls. Only supported for OpenAI.
Show child attributes
The ID of the tool call.
The function that the model called.
Show child attributes
The name of the function to call.
The arguments to call the function with, as generated by the model in JSON format. Note that the model does not always generate valid JSON, and may hallucinate parameters not defined by your function schema. Validate the arguments in your code before calling your function.
The role of the messages author.
MESSAGE_ROLE_UNSPECIFIED, MESSAGE_ROLE_SYSTEM, MESSAGE_ROLE_USER, MESSAGE_ROLE_ASSISTANT, MESSAGE_ROLE_TOOL The time when the chat completion was created.
Usage statistics for the completion request.
Show child attributes
Number of tokens in the generated completion.
Number of tokens in the prompt.
Estimated number of tokens in a streaming response chunk.
Estimated number of tokens for the prompt before the final chunk arrives with the accurate number.
Was this page helpful?