gpt-5.1-chat-latest

This documentation is valid for the following list of our models:

  • openai/gpt-5-1-chat-latest

Model Overview

An advanced conversational AI model delivering enhanced intelligence, warmth, and responsiveness. Designed as a low-latency, highly interactive model, it offers users a natural, engaging, and adaptive conversational experience.

How to Make a Call

Step-by-Step Instructions

1️ Setup You Can’t Skip

▪️ Create an Account: Visit the AI/ML API website and create an account (if you don’t have one yet). ▪️ Generate an API Key: After logging in, navigate to your account dashboard and generate your API key. Ensure that key is enabled on UI.

2️ Copy the code example

At the bottom of this page, you'll find a code example that shows how to structure the request. Choose the code snippet in your preferred programming language and copy it into your development environment.

3️ Modify the code example

▪️ Replace <YOUR_AIMLAPI_KEY> with your actual AI/ML API key from your account. ▪️ Insert your question or request into the content field—this is what the model will respond to.

4️ (Optional) Adjust other optional parameters if needed

Only model and messages are required parameters for this model (and we’ve already filled them in for you in the example), but you can include optional parameters if needed to adjust the model’s behavior. Below, you can find the corresponding API schema, which lists all available parameters along with notes on how to use them.

5️ Run your modified code

Run your modified code in your development environment. Response time depends on various factors, but for simple prompts it rarely exceeds a few seconds.

API Schema

post
Body
modelstring · enumRequiredPossible values:
max_completion_tokensinteger · min: 1Optional

An upper bound for the number of tokens that can be generated for a completion, including visible output tokens and reasoning tokens.

max_tokensnumber · min: 1Optional

The maximum number of tokens that can be generated in the chat completion. This value can be used to control costs for text generated via API.

streambooleanOptional

If set to True, the model response data will be streamed to the client as it is generated using server-sent events.

Default: false
tool_choiceany ofOptional

Controls which (if any) tool is called by the model. none means the model will not call any tool and instead generates a message. auto means the model can pick between generating a message or calling one or more tools. required means the model must call one or more tools. Specifying a particular tool via {"type": "function", "function": {"name": "my_function"}} forces the model to call that tool. none is the default when no tools are present. auto is the default if tools are present.

string · enumOptional

none means the model will not call any tool and instead generates a message. auto means the model can pick between generating a message or calling one or more tools. required means the model must call one or more tools.

Possible values:
or
parallel_tool_callsbooleanOptional

Whether to enable parallel function calling during tool use.

ninteger | nullableOptional

How many chat completion choices to generate for each input message. Note that you will be charged based on the number of generated tokens across all of the choices. Keep n as 1 to minimize costs.

seedinteger · min: 1Optional

This feature is in Beta. If specified, our system will make a best effort to sample deterministically, such that repeated requests with the same seed and parameters should return the same result.

response_formatone ofOptional

An object specifying the format that the model must output.

or
or
Responses
200Success
post
/v1/chat/completions
async function main() {
  const response = await fetch('https://api.aimlapi.com/v1/chat/completions', {
    method: 'POST',
    headers: {
      'Authorization': 'Bearer <YOUR_AIMLAPI_KEY>',
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      model: 'openai/gpt-5-1-chat-latest',
      messages:[
          {
              role:'user',
              content: 'Hello'
          }
      ],
    }),
  });

  const data = await response.json();
  console.log(JSON.stringify(data, null, 2));
}

main();
200Success
{
  "id": "text",
  "object": "text",
  "created": 1,
  "choices": [
    {
      "index": 1,
      "message": {
        "role": "text",
        "content": "text",
        "refusal": null,
        "annotations": [
          {
            "type": "text",
            "url_citation": {
              "end_index": 1,
              "start_index": 1,
              "title": "text",
              "url": "text"
            }
          }
        ],
        "audio": {
          "id": "text",
          "data": "text",
          "transcript": "text",
          "expires_at": 1
        },
        "tool_calls": [
          {
            "id": "text",
            "type": "text",
            "function": {
              "arguments": "text",
              "name": "text"
            }
          }
        ]
      },
      "finish_reason": "stop",
      "logprobs": {
        "content": [
          {
            "bytes": [
              1
            ],
            "logprob": 1,
            "token": "text",
            "top_logprobs": [
              {
                "bytes": [
                  1
                ],
                "logprob": 1,
                "token": "text"
              }
            ]
          }
        ],
        "refusal": []
      }
    }
  ],
  "model": "text",
  "usage": {
    "prompt_tokens": 1,
    "completion_tokens": 1,
    "total_tokens": 1,
    "completion_tokens_details": {
      "accepted_prediction_tokens": 1,
      "audio_tokens": 1,
      "reasoning_tokens": 1,
      "rejected_prediction_tokens": 1
    },
    "prompt_tokens_details": {
      "audio_tokens": 1,
      "cached_tokens": 1
    }
  }
}

Responses Endpoint

This endpoint is currently used only with OpenAI models. Some models support both the /chat/completions and /responses endpoints, while others support only one of them. OpenAI has announced plans to expand the capabilities of the /responses endpoint in the future.

post
Body
modelstring · enumRequiredPossible values:
inputany ofRequired

Text, image, or file inputs to the model, used to generate a response.

stringOptional

A text input to the model, equivalent to a text input with the user role.

or
or
or
or
or
or
or
or
or
or
or
or
max_output_tokensintegerOptional

An upper bound for the number of tokens that can be generated for a response, including visible output tokens and reasoning tokens.

previous_response_idstring | nullableOptional

The unique ID of the previous response to the model. Use this to create multi-turn conversations.

storeboolean | nullableOptional

Whether to store the generated model response for later retrieval via API.

Default: false
streamboolean | nullableOptional

If set to true, the model response data will be streamed to the client as it is generated using server-sent events.

Default: false
truncationstring · enumOptional

The truncation strategy to use for the model response.

- auto: If the context of this response and previous ones exceeds the model's context window size, the model will truncate the response to fit the context window by dropping input items in the middle of the conversation.
- disabled (default): If a model response will exceed the context window size for a model, the request will fail with a 400 error.
Default: disabledPossible values:
tool_choiceany ofOptional

How the model should select which tool (or tools) to use when generating a response.

string · enumOptional

Controls which (if any) tool is called by the model.

none means the model will not call any tool and instead generates a message.

auto means the model can pick between generating a message or calling one or more tools.

required means the model must call one or more tools.

Possible values:
or
or
Responses
200Success
post
/v1/responses
async function main() {
  const response = await fetch('https://api.aimlapi.com/v1/responses', {
    method: 'POST',
    headers: {
      'Authorization': 'Bearer <YOUR_API_KEY>',
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      "model": "openai/gpt-5-1-chat-latest",
      "input": "Hello"
    }),
  });

  const data = await response.json();
  console.log(JSON.stringify(data, null, 2));
}

main();
200Success
{
  "background": null,
  "created_at": 1,
  "error": {
    "code": "text",
    "message": "text"
  },
  "id": "text",
  "incomplete_details": {
    "reason": "text"
  },
  "instructions": "text",
  "max_output_tokens": 1,
  "metadata": {
    "ANY_ADDITIONAL_PROPERTY": "anything"
  },
  "model": "text",
  "object": "text",
  "output": [
    {
      "role": null,
      "type": null,
      "content": null
    }
  ],
  "output_text": null,
  "parallel_tool_calls": true,
  "previous_response_id": null,
  "prompt": {
    "id": "text",
    "variables": {
      "ANY_ADDITIONAL_PROPERTY": "anything"
    },
    "version": null
  },
  "reasoning": {
    "effort": "low",
    "summary": "auto"
  },
  "service_tier": null,
  "status": "completed",
  "temperature": 1,
  "text": {
    "format": {
      "type": "text"
    }
  },
  "tool_choice": "none",
  "tools": [
    {
      "type": "web_search_preview",
      "search_context_size": "low",
      "user_location": {
        "type": "text",
        "city": null,
        "country": null,
        "region": null,
        "timezone": null
      }
    }
  ],
  "top_p": null,
  "truncation": "auto",
  "usage": {
    "input_tokens": 1,
    "input_tokens_details": {
      "cached_tokens": 1
    },
    "output_tokens": 1,
    "output_tokens_details": {
      "reasoning_tokens": 1
    },
    "total_tokens": 1
  }
}

Code Example

import requests
import json  # for getting a structured output with indentation 

response = requests.post(
    "https://api.aimlapi.com/v1/chat/completions",
    headers={
        # Insert your AIML API Key instead of <YOUR_AIMLAPI_KEY>:
        "Authorization":"Bearer <YOUR_AIMLAPI_KEY>",
        "Content-Type":"application/json"
    },
    json={
        "model":"openai/gpt-5-1-chat-latest",
        "messages":[
            {
                "role":"user",
                "content":"Hello"  # insert your prompt here, instead of Hello
            }
        ]
    }
)

data = response.json()
print(json.dumps(data, indent=2, ensure_ascii=False))
Response
{
  "id": "chatcmpl-Cbr2xJaeoD76fVtuBcoIIrfVjGsIu",
  "object": "chat.completion",
  "created": 1763138083,
  "model": "gpt-5.1-chat-latest",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "Hello! How can I help you today?",
        "refusal": null,
        "annotations": []
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 7,
    "completion_tokens": 12,
    "total_tokens": 19,
    "prompt_tokens_details": {
      "cached_tokens": 0,
      "audio_tokens": 0
    },
    "completion_tokens_details": {
      "reasoning_tokens": 0,
      "audio_tokens": 0,
      "accepted_prediction_tokens": 0,
      "rejected_prediction_tokens": 0
    }
  },
  "service_tier": "default",
  "system_fingerprint": null
}

Code Example #2: Using /responses Endpoint

import requests
import json   # for getting a structured output with indentation

response = requests.post(
    "https://api.aimlapi.com/v1/responses",
    headers={
        "Content-Type":"application/json", 

        # Insert your AIML API Key instead of <YOUR_AIMLAPI_KEY>:
        "Authorization":"Bearer <YOUR_AIMLAPI_KEY>",
        "Content-Type":"application/json"
    },
    json={
        "model":"openai/gpt-5-1-chat-latest",
        "input":"Hello"  # Insert your question for the model here, instead of Hello   
    }
)

data = response.json()
print(json.dumps(data, indent=2, ensure_ascii=False))
Response
{
  "id": "resp_0631acadb98188f30069175b4ad34881908b8dc68c29a730bf",
  "object": "response",
  "created_at": 1763138379,
  "error": null,
  "incomplete_details": null,
  "instructions": null,
  "max_output_tokens": 512,
  "model": "gpt-5.1-chat-latest",
  "output": [
    {
      "id": "msg_0631acadb98188f30069175b4bb8f481909d2f56504c2acee3",
      "type": "message",
      "status": "completed",
      "content": [
        {
          "type": "output_text",
          "annotations": [],
          "logprobs": [],
          "text": "Hello. How can I help?"
        }
      ],
      "role": "assistant"
    }
  ],
  "parallel_tool_calls": true,
  "previous_response_id": null,
  "reasoning": {
    "effort": "medium",
    "summary": null
  },
  "temperature": 1,
  "text": {
    "format": {
      "type": "text"
    },
    "verbosity": "medium"
  },
  "tool_choice": "auto",
  "tools": [],
  "top_p": 1,
  "truncation": "disabled",
  "usage": {
    "input_tokens": 18,
    "input_tokens_details": {
      "cached_tokens": 0
    },
    "output_tokens": 231,
    "output_tokens_details": {
      "reasoning_tokens": 0
    },
    "total_tokens": 249
  },
  "metadata": {},
  "output_text": "Hello. How can I help?"
}

Last updated

Was this helpful?