> ## Documentation Index
> Fetch the complete documentation index at: https://docs.gmicloud.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# GPT-5.1 Chat

> GPT-5.1 Chat (AKA Instant is the fast, lightweight member of the 5.1 family, optimized for low-latency chat while retaining strong general intelligence.

**Model ID**

```bash theme={null}
openai/gpt-5.1-chat
```

##

* [API Usage](#api-usage)
* [API Examples](#api-examples)
  * [Create chat completion](#create-chat-completion)
    * [Default](#default)
    * [Streaming](#streaming)
    * [Image Input](#image-input)
    * [Functions](#functions)
    * [Python](#python)
  * [Create a model response](#create-a-model-response)
    * [Default (Responses)](#default-1)
    * [Streaming (Responses)](#streaming-1)
    * [Reasoning](#reasoning)
    * [Functions (Responses)](#functions-1)
    * [Image Input (Responses)](#image-input-1)
    * [File Input](#file-input)
    * [Web search](#web-search)

GPT-5.1 Chat (AKA Instant is the fast, lightweight member of the 5.1 family, optimized for low-latency chat while retaining strong general intelligence. It uses adaptive reasoning to selectively “think” on harder queries, improving accuracy on math, coding, and multi-step tasks without slowing down typical conversations. The model is warmer and more conversational by default, with better instruction following and more stable short-form reasoning. GPT-5.1 Chat is designed for high-throughput, interactive workloads where responsiveness and consistency matter more than deep deliberation.

## API Usage

You can interact with the OpenAI GPT-5.1-chat model through various programming languages and methods. Below are examples showing how to use the model's API.

## API Examples

Generate a model response using the chat endpoint of OpenAI GPT-5.1 chat.

### Create chat completion

The Chat Completions API endpoint will generate a model response from a list of messages comprising a conversation.

#### Default

```bash theme={null}
curl https://api.gmi-serving.com/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $GMI_API_KEY" \
  -d '{
    "model": "openai/gpt-5.1-chat",
    "messages": [
      {
        "role": "developer",
        "content": "You are a helpful assistant."
      },
      {
        "role": "user",
        "content": "Hello!"
      }
    ]
  }'
```

```python theme={null}
from openai import OpenAI

endpoint = "https://api.gmi-serving.com/v1/"
model_name = "openai/gpt-5.1-chat"

api_key = "<gmi-api-key>"

client = OpenAI(
    base_url=f"{endpoint}",
    api_key=api_key
)

completion = client.chat.completions.create(
    model=model_name,
    messages=[
        {
            "role": "user",
            "content": "What is the capital of France?",
        }
    ],
)

print(completion.choices[0].message)
```

#### Streaming

```bash theme={null}
curl https://api.gmi-serving.com/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $GMI_API_KEY" \
  -d '{
    "model": "openai/gpt-5.1-chat",
    "messages": [
      {
        "role": "developer",
        "content": "You are a helpful assistant."
      },
      {
        "role": "user",
        "content": "Hello!"
      }
    ],
    "stream": true
  }'
```

```python theme={null}
from openai import OpenAI

endpoint = "https://api.gmi-serving.com/v1/"
model_name = "openai/gpt-5.1-chat"

api_key = "<gmi-api-key>"

client = OpenAI(
    base_url=f"{endpoint}",
    api_key=api_key
)

completion = client.chat.completions.create(
  model=model_name,
  messages=[
    {"role": "developer", "content": "You are a helpful assistant."},
    {"role": "user", "content": "Hello!"}
  ],
  stream=True
)

for chunk in completion:
  print(chunk.choices[0].delta)

```

#### Image Input

```bash theme={null}
curl https://api.gmi-serving.com/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $GMI_API_KEY" \
  -d '{
    "model": "openai/gpt-5.1-chat",
    "messages": [
      {
        "role": "user",
        "content": [
          {
            "type": "text",
            "text": "What is in this image?"
          },
          {
            "type": "image_url",
            "image_url": {
              "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-VL/assets/demo.jpeg"
            }
          }
        ]
      }
    ],
    "max_completion_tokens": 300
  }'
```

```python theme={null}
from openai import OpenAI

endpoint = "https://api.gmi-serving.com/v1/"
model_name = "openai/gpt-5.1-chat"

api_key = "<gmi-api-key>"

client = OpenAI(
    base_url=f"{endpoint}",
    api_key=api_key
)

completion = client.chat.completions.create(
    model=model_name,
    messages=[
        {
            "role": "user",
            "content": [
                {"type": "text", "text": "What's in this image?"},
                {
                    "type": "image_url",
                    "image_url": {
                        "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-VL/assets/demo.jpeg",
                    }
                },
            ],
        }
    ],
    max_completion_tokens=300,
)

print(response.choices[0])

```

#### Functions

```bash theme={null}
curl https://api.gmi-serving.com/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $GMI_API_KEY" \
  -d '{
    "model": "openai/gpt-5.1-chat",
    "messages": [
      {
        "role": "user",
        "content": "What is the weather like in Boston 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"]
          }
        }
      }
    ],
    "tool_choice": "auto"
  }'
```

```python theme={null}
from openai import OpenAI

endpoint = "https://api.gmi-serving.com/v1/"
model_name = "openai/gpt-5.1-chat"

api_key = "<gmi-api-key>"

client = OpenAI(
    base_url=f"{endpoint}",
    api_key=api_key
)

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"],
      },
    }
  }
]
messages = [{"role": "user", "content": "What's the weather like in Boston today?"}]
completion = client.chat.completions.create(
  model=model_name,
  messages=messages,
  tools=tools,
  tool_choice="auto"
)

print(completion)
```

#### Python

```python theme={null}
import requests
import json

url = "https://api.gmi-serving.com/v1/chat/completions"
headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer *************"
}

payload = {
    "model": "openai/gpt-5.1-chat",
    "messages": [
        {"role": "system", "content": "You are a helpful AI assistant"},
        {"role": "user", "content": "List 3 countries and their capitals."}
    ],
    "temperature": 0,
    "max_completion_tokens": 500
}

response = requests.post(url, headers=headers, json=payload)
print(json.dumps(response.json(), indent=2))
```

### Create a model response

OpenAI's most advanced interface for generating model responses. Supports text and image inputs, and text outputs. Create stateful interactions with the model, using the output of previous responses as input. Extend the model's capabilities with built-in tools for file search, web search, computer use, and more. Allow the model access to external systems and data using function calling.

#### Default

```bash theme={null}
curl https://api.gmi-serving.com/v1/responses \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $GMI_API_KEY" \
  -d '{
    "model": "openai/gpt-5.1-chat",
    "input": "Tell me a three sentence bedtime story about a unicorn."
  }'
```

#### Streaming

```bash theme={null}
curl https://api.gmi-serving.com/v1/responses \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $GMI_API_KEY" \
  -d '{
    "model": "openai/gpt-5.1-chat",
    "instructions": "You are a helpful assistant.",
    "input": "Hello!",
    "stream": true
  }'
```

#### Reasoning

```bash theme={null}
curl https://api.gmi-serving.com/v1/responses \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $GMI_API_KEY" \
  -d '{
    "model": "openai/gpt-5.1-chat",
    "input": "How much wood would a woodchuck chuck?",
    "reasoning": {
      "effort": "medium"
    }
  }'
```

#### Functions

```bash theme={null}
curl https://api.gmi-serving.com/v1/responses \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $GMI_API_KEY" \
  -d '{
    "model": "openai/gpt-5.1-chat",
    "input": "What is the weather like in Boston today?",
    "tools": [
      {
        "type": "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",
              "description": "Temperature unit",
              "enum": ["celsius", "fahrenheit"]
            }
          },
          "required": ["location", "unit"]
        }
      }
    ],
    "tool_choice": "auto"
  }'
```

#### Image Input

```bash theme={null}
curl https://api.gmi-serving.com/v1/responses \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $GMI_API_KEY" \
  -d '{
    "model": "openai/gpt-5.1-chat",
    "input": [
      {
        "role": "user",
        "content": [
          {"type": "input_text", "text": "what is in this image?"},
          {
            "type": "input_image",
            "image_url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-VL/assets/demo.jpeg"
          }
        ]
      }
    ]
  }'
```

#### File Input

```bash theme={null}
curl https://api.gmi-serving.com/v1/responses \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $GMI_API_KEY" \
  -d '{
    "model": "openai/gpt-5.1-chat",
    "input": [
      {
        "role": "user",
        "content": [
          {"type": "input_text", "text": "what is in this file?"},
          {
            "type": "input_file",
            "file_url": "https://www.berkshirehathaway.com/letters/2024ltr.pdf"
          }
        ]
      }
    ]
  }'
```

#### Web search

```bash theme={null}
curl https://api.gmi-serving.com/v1/responses \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $GMI_API_KEY" \
  -d '{
    "model": "openai/gpt-5.1-chat",
    "tools": [{ "type": "web_search_preview" }],
    "input": "What was a positive news story from today?"
  }'
```
