---
updatedAt: 2026-10-15T16:55:48.000Z
---

# Create a chat completion

Supports text, up to eight images, function tools, and streaming. Video and audio inputs are unsupported. With stream=true, consume data-only SSE events until data: [DONE]; reasoning, content, and tool calls arrive as deltas.

# OpenAPI definition

```json
{
  "openapi": "3.1.0",
  "info": {
    "title": "Step 5 Preview Chat Completions API",
    "version": "1.0.0",
    "description": "Generate text from text and image conversations with stepfun-ai/step-5-preview. This preview uses reasoning on every turn. Responses separate reasoning_content from the final content; disabling reasoning is unsupported. The combined prompt and generated response must fit within the 1,048,576-token context window."
  },
  "servers": [
    {
      "url": "https://integrate.api.nvidia.com"
    }
  ],
  "security": [
    {
      "BearerAuth": []
    }
  ],
  "paths": {
    "/v1/chat/completions": {
      "post": {
        "summary": "Create a chat completion",
        "description": "Supports text, up to eight images, function tools, and streaming. Video and audio inputs are unsupported. With stream=true, consume data-only SSE events until data: [DONE]; reasoning, content, and tool calls arrive as deltas.",
        "operationId": "stepfun-ai-step-5-preview-infer",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ChatCompletionRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "A chat completion, or SSE chunks when streaming is enabled.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ChatCompletionResponse"
                }
              },
              "text/event-stream": {
                "schema": {
                  "type": "string",
                  "description": "JSON chat.completion.chunk events followed by data: [DONE]."
                }
              }
            }
          },
          "400": {
            "description": "Invalid request or unsupported input."
          },
          "401": {
            "description": "Missing or invalid NVIDIA API key."
          },
          "402": {
            "description": "Insufficient API credits."
          },
          "422": {
            "description": "Request validation failed."
          },
          "429": {
            "description": "Request rate limit exceeded."
          }
        },
        "x-nvai-meta": {
          "name": "Create chat completion",
          "path": "create",
          "examples": [],
          "templates": [
            {
              "title": "Chat completion"
            }
          ]
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "BearerAuth": {
        "type": "http",
        "scheme": "bearer"
      }
    },
    "schemas": {
      "ChatCompletionRequest": {
        "type": "object",
        "required": [
          "model",
          "messages"
        ],
        "properties": {
          "model": {
            "type": "string",
            "default": "stepfun-ai/step-5-preview",
            "enum": [
              "stepfun-ai/step-5-preview"
            ],
            "title": "Model"
          },
          "messages": {
            "type": "array",
            "minItems": 1,
            "description": "Conversation history. Use content-part arrays for images. After an assistant tool call, include a tool message with its tool_call_id. Preserve assistant reasoning_content when continuing a conversation.",
            "items": {
              "$ref": "#/components/schemas/ChatMessage"
            },
            "title": "Messages"
          },
          "max_tokens": {
            "type": "integer",
            "minimum": 1,
            "maximum": 1048576,
            "default": 4096,
            "description": "Maximum generated tokens, including reasoning and the final answer. Small budgets may end during reasoning with null content and finish_reason=length. Prompt plus output must fit the context window.",
            "title": "Max Tokens"
          },
          "stream": {
            "type": "boolean",
            "default": false,
            "title": "Stream"
          },
          "temperature": {
            "type": "number",
            "minimum": 0,
            "maximum": 2,
            "default": 0.5,
            "title": "Temperature"
          },
          "top_p": {
            "type": "number",
            "exclusiveMinimum": 0,
            "maximum": 1,
            "default": 1,
            "title": "Top P"
          },
          "frequency_penalty": {
            "type": "number",
            "minimum": -2,
            "maximum": 2,
            "default": 0,
            "title": "Frequency Penalty"
          },
          "presence_penalty": {
            "type": "number",
            "minimum": -2,
            "maximum": 2,
            "default": 0,
            "title": "Presence Penalty"
          },
          "seed": {
            "type": "integer",
            "minimum": 0,
            "maximum": 9007199254740991,
            "description": "Optional sampling seed, limited to JavaScript-safe integers for the interactive examples. Deterministic output is not guaranteed.",
            "title": "Seed"
          },
          "stop": {
            "description": "Stop string or list of stop strings; omitted from the output.",
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              {
                "type": "null"
              }
            ],
            "title": "Stop"
          },
          "tools": {
            "type": "array",
            "description": "Functions the model may request; the caller executes them.",
            "items": {
              "$ref": "#/components/schemas/FunctionTool"
            },
            "title": "Tools"
          },
          "tool_choice": {
            "description": "Choose auto, none, required, or force a named function.",
            "anyOf": [
              {
                "type": "string",
                "enum": [
                  "auto",
                  "none",
                  "required"
                ]
              },
              {
                "type": "object",
                "required": [
                  "type",
                  "function"
                ],
                "properties": {
                  "type": {
                    "type": "string",
                    "const": "function",
                    "title": "Type"
                  },
                  "function": {
                    "type": "object",
                    "required": [
                      "name"
                    ],
                    "properties": {
                      "name": {
                        "type": "string",
                        "title": "Name"
                      }
                    },
                    "title": "Function"
                  }
                }
              }
            ],
            "title": "Tool Choice"
          },
          "chat_template_kwargs": {
            "type": "object",
            "description": "Reasoning remains enabled on this checkpoint. Do not set enable_thinking=false: it does not stop reasoning generation.",
            "properties": {
              "enable_thinking": {
                "type": "boolean",
                "const": true,
                "enum": [
                  true
                ],
                "default": true,
                "title": "Enable Thinking"
              },
              "preserve_thinking": {
                "type": "boolean",
                "default": true,
                "description": "Preserve reasoning from earlier assistant turns in the prompt.",
                "title": "Preserve Thinking"
              }
            },
            "title": "Chat Template Kwargs"
          }
        },
        "title": "ChatCompletionRequest"
      },
      "ChatMessage": {
        "type": "object",
        "required": [
          "role"
        ],
        "properties": {
          "role": {
            "type": "string",
            "enum": [
              "system",
              "user",
              "assistant",
              "tool"
            ],
            "title": "Role"
          },
          "content": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              },
              {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/ContentPart"
                }
              }
            ],
            "title": "Content"
          },
          "reasoning_content": {
            "type": [
              "string",
              "null"
            ],
            "description": "Assistant reasoning, separate from the final answer.",
            "title": "Reasoning Content"
          },
          "tool_calls": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ToolCall"
            },
            "title": "Tool Calls"
          },
          "tool_call_id": {
            "type": "string",
            "description": "Required on tool-result messages; matches an assistant tool call ID.",
            "title": "Tool Call Id"
          },
          "name": {
            "type": "string",
            "title": "Name"
          }
        },
        "title": "ChatMessage"
      },
      "ContentPart": {
        "oneOf": [
          {
            "type": "object",
            "required": [
              "type",
              "text"
            ],
            "properties": {
              "type": {
                "type": "string",
                "const": "text",
                "title": "Type"
              },
              "text": {
                "type": "string",
                "title": "Text"
              }
            }
          },
          {
            "type": "object",
            "required": [
              "type",
              "image_url"
            ],
            "properties": {
              "type": {
                "type": "string",
                "const": "image_url",
                "title": "Type"
              },
              "image_url": {
                "type": "object",
                "required": [
                  "url"
                ],
                "properties": {
                  "url": {
                    "type": "string",
                    "description": "HTTPS image URL or base64 data URL. PNG, JPEG, or WebP; at most eight images per request.",
                    "title": "Url"
                  },
                  "detail": {
                    "type": "string",
                    "enum": [
                      "auto",
                      "low",
                      "high"
                    ],
                    "title": "Detail"
                  }
                },
                "title": "Image Url"
              }
            }
          }
        ],
        "title": "ContentPart"
      },
      "FunctionTool": {
        "type": "object",
        "required": [
          "type",
          "function"
        ],
        "properties": {
          "type": {
            "type": "string",
            "const": "function",
            "title": "Type"
          },
          "function": {
            "type": "object",
            "required": [
              "name"
            ],
            "properties": {
              "name": {
                "type": "string",
                "title": "Name"
              },
              "description": {
                "type": "string",
                "title": "Description"
              },
              "parameters": {
                "type": "object",
                "description": "JSON Schema for the function arguments.",
                "title": "Parameters"
              }
            },
            "title": "Function"
          }
        },
        "title": "FunctionTool"
      },
      "ToolCall": {
        "type": "object",
        "required": [
          "id",
          "type",
          "function"
        ],
        "properties": {
          "id": {
            "type": "string",
            "title": "Id"
          },
          "type": {
            "type": "string",
            "const": "function",
            "title": "Type"
          },
          "function": {
            "type": "object",
            "required": [
              "name",
              "arguments"
            ],
            "properties": {
              "name": {
                "type": "string",
                "title": "Name"
              },
              "arguments": {
                "type": "string",
                "description": "JSON-encoded function arguments; parse and validate before execution.",
                "title": "Arguments"
              }
            },
            "title": "Function"
          }
        },
        "title": "ToolCall"
      },
      "ChatCompletionResponse": {
        "type": "object",
        "required": [
          "model",
          "choices"
        ],
        "properties": {
          "id": {
            "type": "string",
            "title": "Id"
          },
          "object": {
            "type": "string",
            "default": "chat.completion",
            "title": "Object"
          },
          "created": {
            "type": "integer",
            "title": "Created"
          },
          "model": {
            "type": "string",
            "title": "Model"
          },
          "choices": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "index",
                "message",
                "finish_reason"
              ],
              "properties": {
                "index": {
                  "type": "integer",
                  "title": "Index"
                },
                "message": {
                  "$ref": "#/components/schemas/ChatMessage",
                  "title": "Message"
                },
                "finish_reason": {
                  "type": [
                    "string",
                    "null"
                  ],
                  "enum": [
                    "stop",
                    "length",
                    "tool_calls",
                    "content_filter",
                    null
                  ],
                  "title": "Finish Reason"
                }
              }
            },
            "title": "Choices"
          },
          "usage": {
            "type": [
              "object",
              "null"
            ],
            "properties": {
              "prompt_tokens": {
                "type": "integer",
                "title": "Prompt Tokens"
              },
              "completion_tokens": {
                "type": "integer",
                "title": "Completion Tokens"
              },
              "total_tokens": {
                "type": "integer",
                "title": "Total Tokens"
              }
            },
            "title": "Usage"
          }
        },
        "title": "ChatCompletionResponse"
      }
    }
  }
}
```