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

# Responses API

Call the Responses API to get the model-generated response data. This endpoint is compatible with the OpenAI Responses API request and response format.

## Endpoint

`POST https://api.stepfun.ai/v1/responses`

## Request Parameters

* `model` `string` ***required***\
  Name of the model to use. Currently supported models are `step-5-preview` and `step-3.7-flash`.
* `input` `string or object array` ***required***\
  Input content. Either a plain text string, or an ordered array of messages / events.

  * Plain text input `string`\
    Equivalent to a single text message with `role=user`.
  * Message / event array `object array`\
    Each element may be one of the following types:
    * Text message `object`
      * `role` `string`\
        Message role. Valid values: `user`, `assistant`, `system`.
      * `content` `string or object array`\
        Message content. Either a plain text string, or an array of content blocks for multimodal input.
        * Plain text content `string`
        * Content block array `object array`
          * Text block `object`
            * `type` `string`\
              Always `input_text`.
            * `text` `string`\
              Text content.
          * Image block `object`
            * `type` `string`\
              Always `input_image`.
            * `image_url` `string or object`\
              Image source. Either a string, or an object `{ "url": "...", "detail": "high" }`. Base64 data URLs (format `data:image/jpeg;base64,${base64_string}`) are recommended; otherwise the external URL must be publicly reachable from the server.
          * Video block `object`
            * `type` `string`\
              Always `input_video`.
            * `video_url` `string or object`\
              Video source. Either a string, or an object `{ "url": "...", "detail": "low" }`. The video URL must be publicly reachable from the server.
    * Function call `object` (returned by the model in a previous turn; must be passed back verbatim in multi-turn conversations)
      * `type` `string`\
        Always `function_call`.
      * `id` `string`\
        Unique ID for the function call, generated by the server.
      * `call_id` `string`\
        Correlation ID used to pair with the subsequent `function_call_output`.
      * `name` `string`\
        Tool name.
      * `arguments` `string`\
        Arguments as a JSON string.
    * Function call output `object` (returned by the client after executing the tool)
      * `type` `string`\
        Always `function_call_output`.
      * `call_id` `string`\
        The `call_id` of the matching `function_call`.
      * `output` `string`\
        Tool execution result (JSON string recommended).

> [!NOTE]
>
> Image and video URLs must be publicly reachable from the server; if the server cannot fetch the URL, a parameter error will be returned. For image input, base64 data URLs are recommended to avoid authentication, hotlink protection, or network access failures on external URLs.

* `instructions` `string` ***optional***\
  Top-level system instructions.
* `stream` `bool` ***optional***\
  Whether to enable SSE streaming. Default is `false`.
* `temperature` `float` ***optional***\
  Sampling temperature, between 0.0 and 2.0.
* `top_p` `float` ***optional***\
  Nucleus sampling parameter.
* `max_output_tokens` `int` ***optional***\
  Maximum number of output tokens for this response.

> [!NOTE]
>
> `max_output_tokens` limits both the reasoning process and the final output. When using `medium` / `high` reasoning effort, JSON Schema, video, or other complex inputs, reserve a larger output budget; if the budget is insufficient, the response may return `status="incomplete"`, and `output` may contain only a `reasoning` item without a final `message`.

* `reasoning` `object` ***optional***\
  Reasoning configuration.

  * `effort` `string` ***optional***\
    Reasoning effort level. Valid values: `low` / `medium` / `high`.

* `tools` `object array` ***optional***\
  List of tool definitions. Currently only `function`-type tools are supported.

  * `type` `string`\
    Always `function`.
  * `name` `string`\
    Function name. Letters, digits, and `_-` are recommended.
  * `description` `string` ***optional***\
    Function description — helps the model decide whether to call the tool.
  * `parameters` `object`\
    JSON Schema describing the function arguments.
  * `strict` `boolean` ***optional***\
    Whether to enable strict mode. When enabled, the model's output arguments will strictly match the schema in `parameters`.

* `tool_choice` `string or object` ***optional***\
  Tool-call strategy. Currently only the string `"auto"` is supported (the model decides whether to call a tool).

* `text` `object` ***optional***\
  Text output format configuration.

  * `format` `object`
    * `type` `string`\
      One of `text`, `json_object`, or `json_schema`.
    * `name` `string` ***optional***\
      Required when `type=json_schema`. The schema's identifier name.
    * `strict` `boolean` ***optional***\
      Available when `type=json_schema`. When enabled, the model's output will strictly match the schema.
    * `schema` `object` ***optional***\
      Required when `type=json_schema`. An object following the [JSON Schema](https://json-schema.org/) specification.

## Response Format

### Non-streaming response

When `stream=false` (default), a single Response object is returned.

#### Properties

* `id` `string`\
  Unique response ID, in the form `resp_xxx`.

* `object` `string`\
  Always `response`.

* `created_at` `int`\
  Creation time as a Unix timestamp (seconds).

* `completed_at` `int or null`\
  Completion time as a Unix timestamp (seconds).

* `status` `string`\
  Response status. One of `completed`, `incomplete`, or `failed`.

* `error` `object or null`\
  Error information. Non-null only when `status=failed`.

* `incomplete_details` `object or null`\
  Incomplete details. Non-null only when `status=incomplete`; commonly `{ "reason": "max_output_tokens" }`.

* `model` `string`\
  The model ID actually used.

* `output` `object array`\
  Array of output items. Each element may be of one of the following types:

  * Reasoning item `object`
    * `type` `string`\
      Always `reasoning`.
    * `id` `string`\
      Reasoning item ID.
    * `status` `string or null`\
      Reasoning item status; may be `completed` upon streaming completion.
    * `summary` `object array`\
      Reasoning summary list; usually an empty array.
    * `content` `object or null`\
      Reasoning content; usually `null`.
    * `encrypted_content` `string or null`\
      Encrypted reasoning content; usually `null`.
  * Text message `object`
    * `type` `string`\
      Always `message`.
    * `id` `string`\
      Message ID.
    * `role` `string`\
      Always `assistant`.
    * `status` `string`\
      Always `completed`.
    * `content` `object array`
      * `type` `string`\
        Always `output_text`.
      * `text` `string`\
        Text content generated by the model.
      * `annotations` `object array`\
        List of annotations. Empty array when there are no annotations.
  * Function call `object`
    * `type` `string`\
      Always `function_call`.
    * `id` `string`\
      Unique function-call ID.
    * `call_id` `string`\
      Correlation ID. Must be passed back with the `function_call_output`.
    * `name` `string`\
      Name of the tool being called.
    * `arguments` `string`\
      Arguments as a JSON string.
    * `status` `string`\
      Always `completed`.

* `usage` `object`\
  Token usage statistics.

  * `input_tokens` `int`\
    Input token count.
  * `input_tokens_details` `object`
    * `cached_tokens` `int`\
      Input tokens served from cache.
  * `output_tokens` `int`\
    Output token count.
  * `output_tokens_details` `object`
    * `reasoning_tokens` `int`\
      Output tokens used for reasoning.
    * `tool_output_tokens` `int`\
      Output tokens used for tool output.
  * `total_tokens` `int`\
    Total token count.

* `instructions` `string or null`\
  Echoes the top-level instructions from the request.

* `max_output_tokens` `int or null`\
  Echoes the request parameter.

* `reasoning` `object or null`\
  Echoes the reasoning configuration.

* `temperature` `float or null`\
  Echoes the sampling temperature.

* `top_p` `float or null`\
  Echoes the nucleus sampling parameter.

* `text` `object`\
  Echoes the text output format configuration.

  * `format` `object`
    * `type` `string`\
      One of `text`, `json_object`, or `json_schema`.
    * `name` `string`\
      Present when `type=json_schema`. The schema's identifier name.
    * `strict` `boolean`\
      Present when `type=json_schema`.
    * `schema` `object`\
      Present when `type=json_schema`. An object following the [JSON Schema](https://json-schema.org/) specification.

* `tool_choice` `string or object`\
  Echoes the tool-call strategy.

* `tools` `object array`\
  Echoes the tool definitions.

#### Example

```json theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
{
  "id": "resp_xxxxxxxxxxxxxxxx",
  "object": "response",
  "created_at": 1772624997,
  "completed_at": 1772624998,
  "model": "step-5-preview",
  "status": "completed",
  "error": null,
  "incomplete_details": null,
  "output": [
    {
      "type": "reasoning",
      "id": "rs_xxxxxxxxxxxxxxxx",
      "summary": [],
      "content": null,
      "encrypted_content": null,
      "status": null
    },
    {
      "type": "message",
      "id": "msg_xxxxxxxxxxxxxxxx",
      "status": "completed",
      "role": "assistant",
      "content": [
        {
          "type": "output_text",
          "text": "Quantum computing is a new computational paradigm that leverages principles of quantum mechanics (such as superposition and entanglement) to process information.",
          "annotations": []
        }
      ]
    }
  ],
  "usage": {
    "input_tokens": 14,
    "input_tokens_details": { "cached_tokens": 0 },
    "output_tokens": 52,
    "output_tokens_details": { "reasoning_tokens": 0, "tool_output_tokens": 0 },
    "total_tokens": 66
  },
  "instructions": null,
  "max_output_tokens": null,
  "reasoning": { "effort": "medium", "summary": null },
  "temperature": 1.0,
  "top_p": 1.0,
  "text": { "format": { "type": "text" } },
  "tool_choice": "auto",
  "tools": []
}
```

### Streaming response

When `stream=true`, Server-Sent Events (SSE) data is returned. Each event consists of an `event:` line and a `data:` line.

Each event's `data` object contains `type` and `sequence_number`. `type` matches the `event` name; `sequence_number` starts from 0 and increments, allowing clients to process events in order.

#### Event types

| Event | Triggered when |
| - | - |
| `response.created` | Response is created |
| `response.in_progress` | Generation begins |
| `response.output_item.added` | A new output item is created |
| `response.reasoning_part.added` | A reasoning content part begins |
| `response.reasoning_text.delta` | Reasoning text delta |
| `response.reasoning_text.done` | Reasoning text finishes |
| `response.reasoning_part.done` | Reasoning content part finishes |
| `response.content_part.added` | A text content part begins |
| `response.output_text.delta` | Text delta |
| `response.output_text.done` | Text part finishes |
| `response.content_part.done` | Content part finishes |
| `response.function_call_arguments.delta` | Tool argument delta |
| `response.function_call_arguments.done` | Tool arguments finish |
| `response.output_item.done` | Output item finishes |
| `response.completed` | Response completes |
| `response.incomplete` | Ended due to output truncation |
| `response.failed` | Generation failed |
| `error` | Transport-layer error |

#### Example

Text streaming:

```text theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
event: response.created
data: {"type":"response.created","sequence_number":0,"response":{"id":"resp_xxx","object":"response","created_at":1772624997,"model":"step-5-preview","status":"in_progress","output":[]}}

event: response.in_progress
data: {"type":"response.in_progress","sequence_number":1,"response":{"id":"resp_xxx","status":"in_progress"}}

event: response.output_item.added
data: {"type":"response.output_item.added","sequence_number":2,"output_index":0,"item":{"id":"rs_xxx","type":"reasoning","summary":[],"content":null,"encrypted_content":null,"status":"in_progress"}}

event: response.reasoning_part.added
data: {"type":"response.reasoning_part.added","sequence_number":3,"output_index":0,"item_id":"rs_xxx","content_index":0,"part":{"type":"reasoning_text","text":""}}

event: response.reasoning_text.delta
data: {"type":"response.reasoning_text.delta","sequence_number":4,"output_index":0,"item_id":"rs_xxx","content_index":0,"delta":"User asked for a greeting."}

event: response.reasoning_text.done
data: {"type":"response.reasoning_text.done","sequence_number":5,"output_index":0,"item_id":"rs_xxx","content_index":0,"text":"User asked for a greeting."}

event: response.reasoning_part.done
data: {"type":"response.reasoning_part.done","sequence_number":6,"output_index":0,"item_id":"rs_xxx","content_index":0,"part":{"type":"reasoning_text","text":"User asked for a greeting."}}

event: response.output_item.done
data: {"type":"response.output_item.done","sequence_number":7,"output_index":0,"item":{"id":"rs_xxx","type":"reasoning","summary":[],"content":null,"encrypted_content":null,"status":"completed"}}

event: response.output_item.added
data: {"type":"response.output_item.added","sequence_number":8,"output_index":1,"item":{"id":"msg_xxx","type":"message","role":"assistant","status":"in_progress","content":[]}}

event: response.content_part.added
data: {"type":"response.content_part.added","sequence_number":9,"item_id":"msg_xxx","output_index":1,"content_index":0,"part":{"type":"output_text","text":"","annotations":[]}}

event: response.output_text.delta
data: {"type":"response.output_text.delta","sequence_number":10,"item_id":"msg_xxx","output_index":1,"content_index":0,"delta":"Hello"}

event: response.output_text.done
data: {"type":"response.output_text.done","sequence_number":11,"item_id":"msg_xxx","output_index":1,"content_index":0,"text":"Hello"}

event: response.content_part.done
data: {"type":"response.content_part.done","sequence_number":12,"item_id":"msg_xxx","output_index":1,"content_index":0,"part":{"type":"output_text","text":"Hello","annotations":[]}}

event: response.output_item.done
data: {"type":"response.output_item.done","sequence_number":13,"output_index":1,"item":{"id":"msg_xxx","type":"message","role":"assistant","status":"completed","content":[{"type":"output_text","text":"Hello","annotations":[]}]}}

event: response.completed
data: {"type":"response.completed","sequence_number":14,"response":{"id":"resp_xxx","object":"response","status":"completed","output":[{"id":"rs_xxx","type":"reasoning","summary":[],"content":null,"encrypted_content":null,"status":"completed"},{"id":"msg_xxx","type":"message","role":"assistant","status":"completed","content":[{"type":"output_text","text":"Hello","annotations":[]}]}],"usage":{"input_tokens":10,"output_tokens":2,"total_tokens":12}}}
```

Function-call streaming (excerpt):

```text theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
event: response.output_item.added
data: {"type":"response.output_item.added","sequence_number":0,"output_index":0,"item":{"id":"fc_xxx","type":"function_call","call_id":"call_xxx","name":"get_weather","arguments":"","status":"in_progress"}}

event: response.function_call_arguments.delta
data: {"type":"response.function_call_arguments.delta","sequence_number":1,"item_id":"fc_xxx","output_index":0,"delta":"{\"city\":\"Beijing\"}"}

event: response.function_call_arguments.done
data: {"type":"response.function_call_arguments.done","sequence_number":2,"item_id":"fc_xxx","output_index":0,"arguments":"{\"city\":\"Beijing\"}","name":"get_weather"}

event: response.output_item.done
data: {"type":"response.output_item.done","sequence_number":3,"output_index":0,"item":{"id":"fc_xxx","type":"function_call","call_id":"call_xxx","name":"get_weather","arguments":"{\"city\":\"Beijing\"}","status":"completed"}}

event: response.completed
data: {"type":"response.completed","sequence_number":4,"response":{"id":"resp_xxx","object":"response","status":"completed","output":[{"id":"fc_xxx","type":"function_call","call_id":"call_xxx","name":"get_weather","arguments":"{\"city\":\"Beijing\"}","status":"completed"}]}}
```

## Examples

> [tab] Basic text
>
> > [tab] python
> >
> > ```python theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
> > from openai import OpenAI
> >
> > client = OpenAI(api_key="YOUR_STEP_API_KEY", base_url="https://api.stepfun.ai/v1")
> >
> > response = client.responses.create(
> >     model="step-5-preview",
> >     input="Briefly introduce quantum computing in one sentence",
> > )
> >
> > print(response.output_text)
> > ```
>
> > [tab] js
> >
> > ```js theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
> > import OpenAI from "openai";
> >
> > const openai = new OpenAI({
> >     apiKey: "YOUR_STEP_API_KEY",
> >     baseURL: "https://api.stepfun.ai/v1"
> > });
> >
> > const response = await openai.responses.create({
> >     model: "step-5-preview",
> >     input: "Briefly introduce quantum computing in one sentence",
> > });
> >
> > console.log(response.output_text);
> > ```
>
> > [tab] curl
> >
> > ```bash theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
> > curl https://api.stepfun.ai/v1/responses \
> >   -H "Content-Type: application/json" \
> >   -H "Authorization: Bearer $STEP_API_KEY" \
> >   -d '{
> >     "model": "step-5-preview",
> >     "input": "Briefly introduce quantum computing in one sentence"
> >   }'
> > ```

> [tab] Multi-turn + function calling
>
> First turn: the model issues a `function_call` based on the tool definition. Second turn: the client passes both the previous `function_call` and the locally executed `function_call_output` back, and the model produces the final answer based on the tool result.
>
> > [tab] python
> >
> > ```python theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
> > from openai import OpenAI
> >
> > client = OpenAI(api_key="YOUR_STEP_API_KEY", base_url="https://api.stepfun.ai/v1")
> >
> > tools = [{
> >     "type": "function",
> >     "name": "get_weather",
> >     "description": "Get the current weather for a city",
> >     "parameters": {
> >         "type": "object",
> >         "properties": {"city": {"type": "string", "description": "City name"}},
> >         "required": ["city"],
> >     },
> >     "strict": True,
> > }]
> >
> > # First turn: the model issues a function_call
> > r1 = client.responses.create(
> >     model="step-5-preview",
> >     input=[{"role": "user", "content": "What's the weather in Beijing today?"}],
> >     tools=tools,
> >     tool_choice="auto",
> > )
> > fc = next(o for o in r1.output if o.type == "function_call")
> >
> > # Client executes the tool (mocked here for demonstration)
> > tool_result = '{"temperature":22,"weather":"sunny","humidity":45}'
> >
> > # Second turn: pass function_call and function_call_output back
> > r2 = client.responses.create(
> >     model="step-5-preview",
> >     input=[
> >         {"role": "user", "content": "What's the weather in Beijing today?"},
> >         {
> >             "type": "function_call",
> >             "id": fc.id,
> >             "call_id": fc.call_id,
> >             "name": fc.name,
> >             "arguments": fc.arguments,
> >         },
> >         {
> >             "type": "function_call_output",
> >             "call_id": fc.call_id,
> >             "output": tool_result,
> >         },
> >     ],
> >     tools=tools,
> > )
> > print(r2.output_text)
> > ```
>
> > [tab] js
> >
> > ```js theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
> > import OpenAI from "openai";
> >
> > const openai = new OpenAI({
> >     apiKey: "YOUR_STEP_API_KEY",
> >     baseURL: "https://api.stepfun.ai/v1"
> > });
> >
> > const tools = [{
> >     type: "function",
> >     name: "get_weather",
> >     description: "Get the current weather for a city",
> >     parameters: {
> >         type: "object",
> >         properties: { city: { type: "string", description: "City name" } },
> >         required: ["city"]
> >     },
> >     strict: true
> > }];
> >
> > // First turn: the model issues a function_call
> > const r1 = await openai.responses.create({
> >     model: "step-5-preview",
> >     input: [{ role: "user", content: "What's the weather in Beijing today?" }],
> >     tools,
> >     tool_choice: "auto"
> > });
> > const fc = r1.output.find(o => o.type === "function_call");
> >
> > // Client executes the tool (mocked here for demonstration)
> > const toolResult = '{"temperature":22,"weather":"sunny","humidity":45}';
> >
> > // Second turn: pass function_call and function_call_output back
> > const r2 = await openai.responses.create({
> >     model: "step-5-preview",
> >     input: [
> >         { role: "user", content: "What's the weather in Beijing today?" },
> >         {
> >             type: "function_call",
> >             id: fc.id,
> >             call_id: fc.call_id,
> >             name: fc.name,
> >             arguments: fc.arguments
> >         },
> >         {
> >             type: "function_call_output",
> >             call_id: fc.call_id,
> >             output: toolResult
> >         }
> >     ],
> >     tools
> > });
> > console.log(r2.output_text);
> > ```
>
> > [tab] curl
> >
> > ```bash theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
> > # First turn: the model issues a function_call
> > curl https://api.stepfun.ai/v1/responses \
> >   -H "Content-Type: application/json" \
> >   -H "Authorization: Bearer $STEP_API_KEY" \
> >   -d '{
> >     "model": "step-5-preview",
> >     "input": [{ "role": "user", "content": "What'\''s the weather in Beijing today?" }],
> >     "tools": [{
> >       "type": "function",
> >       "name": "get_weather",
> >       "description": "Get the current weather for a city",
> >       "parameters": {
> >         "type": "object",
> >         "properties": { "city": { "type": "string", "description": "City name" } },
> >         "required": ["city"]
> >       },
> >       "strict": true
> >     }],
> >     "tool_choice": "auto"
> >   }'
> >
> > # Second turn: pass function_call and function_call_output back (use the call_id returned by the previous turn)
> > curl https://api.stepfun.ai/v1/responses \
> >   -H "Content-Type: application/json" \
> >   -H "Authorization: Bearer $STEP_API_KEY" \
> >   -d '{
> >     "model": "step-5-preview",
> >     "input": [
> >       { "role": "user", "content": "What'\''s the weather in Beijing today?" },
> >       {
> >         "type": "function_call",
> >         "id": "fc_xxxxxxxxxxxxxxxx",
> >         "call_id": "call_xxxxxxxxxxxxxxxx",
> >         "name": "get_weather",
> >         "arguments": "{\"city\":\"Beijing\"}"
> >       },
> >       {
> >         "type": "function_call_output",
> >         "call_id": "call_xxxxxxxxxxxxxxxx",
> >         "output": "{\"temperature\":22,\"weather\":\"sunny\",\"humidity\":45}"
> >       }
> >     ],
> >     "tools": [{
> >       "type": "function",
> >       "name": "get_weather",
> >       "parameters": {
> >         "type": "object",
> >         "properties": { "city": { "type": "string" } },
> >         "required": ["city"]
> >       },
> >       "strict": true
> >     }]
> >   }'
> > ```

> [tab] Multimodal image
>
> Base64 data URLs are recommended:
>
> > [tab] python
> >
> > ```python theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
> > import base64, requests
> > from openai import OpenAI
> >
> > client = OpenAI(api_key="YOUR_STEP_API_KEY", base_url="https://api.stepfun.ai/v1")
> >
> > # Load the image into memory — demo only; adapt to reading from disk as needed
> > r = requests.get("https://www.stepfun.com/assets/section-1-CTe4nZiO.webp")
> > r.raise_for_status()
> > image_data_url = "data:image/webp;base64," + base64.b64encode(r.content).decode("ascii")
> >
> > response = client.responses.create(
> >     model="step-5-preview",
> >     input=[{
> >         "role": "user",
> >         "content": [
> >             {"type": "input_text", "text": "Describe the content of this image"},
> >             {"type": "input_image", "image_url": image_data_url},
> >         ],
> >     }],
> > )
> > print(response.output_text)
> > ```
>
> > [tab] js
> >
> > ```js theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
> > import OpenAI from "openai";
> >
> > const openai = new OpenAI({
> >     apiKey: "YOUR_STEP_API_KEY",
> >     baseURL: "https://api.stepfun.ai/v1"
> > });
> >
> > // Load the image into memory — demo only; adapt to reading from disk as needed
> > async function loadImage(url) {
> >     const res = await fetch(url);
> >     const blob = await res.blob();
> >     const buffer = Buffer.from(await blob.arrayBuffer());
> >     return "data:" + blob.type + ";base64," + buffer.toString("base64");
> > }
> >
> > const imageDataUrl = await loadImage("https://www.stepfun.com/assets/section-1-CTe4nZiO.webp");
> >
> > const response = await openai.responses.create({
> >     model: "step-5-preview",
> >     input: [{
> >         role: "user",
> >         content: [
> >             { type: "input_text", text: "Describe the content of this image" },
> >             { type: "input_image", image_url: imageDataUrl }
> >         ]
> >     }]
> > });
> > console.log(response.output_text);
> > ```
>
> > [tab] curl
> >
> > ```bash theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
> > # Load the image into memory — demo only; adapt to reading from disk as needed
> > image_base64="data:image/webp;base64,"$(curl -s "https://www.stepfun.com/assets/section-1-CTe4nZiO.webp" | base64)
> >
> > curl https://api.stepfun.ai/v1/responses \
> >   -H "Content-Type: application/json" \
> >   -H "Authorization: Bearer $STEP_API_KEY" \
> >   -d "{
> >     \"model\": \"step-5-preview\",
> >     \"input\": [
> >       {
> >         \"role\": \"user\",
> >         \"content\": [
> >           { \"type\": \"input_text\", \"text\": \"Describe the content of this image\" },
> >           { \"type\": \"input_image\", \"image_url\": \"${image_base64}\" }
> >         ]
> >       }
> >     ]
> >   }"
> > ```
>
> You can also use the object form to specify `detail`:
>
> ```json theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
> {
>   "type": "input_image",
>   "image_url": { "url": "data:image/jpeg;base64,...", "detail": "high" }
> }
> ```

> [tab] Multimodal video
>
> Video is passed via URL; the URL must be publicly reachable from the server:
>
> > [tab] python
> >
> > ```python theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
> > from openai import OpenAI
> >
> > client = OpenAI(api_key="YOUR_STEP_API_KEY", base_url="https://api.stepfun.ai/v1")
> >
> > response = client.responses.create(
> >     model="step-5-preview",
> >     input=[{
> >         "role": "user",
> >         "content": [
> >             {"type": "input_text", "text": "Summarize the main content of this video"},
> >             {"type": "input_video", "video_url": {"url": "https://example.com/demo.mp4", "detail": "low"}},
> >         ],
> >     }],
> > )
> > print(response.output_text)
> > ```
>
> > [tab] js
> >
> > ```js theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
> > import OpenAI from "openai";
> >
> > const openai = new OpenAI({
> >     apiKey: "YOUR_STEP_API_KEY",
> >     baseURL: "https://api.stepfun.ai/v1"
> > });
> >
> > const response = await openai.responses.create({
> >     model: "step-5-preview",
> >     input: [{
> >         role: "user",
> >         content: [
> >             { type: "input_text", text: "Summarize the main content of this video" },
> >             { type: "input_video", video_url: { url: "https://example.com/demo.mp4", detail: "low" } }
> >         ]
> >     }]
> > });
> > console.log(response.output_text);
> > ```
>
> > [tab] curl
> >
> > ```bash theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
> > curl https://api.stepfun.ai/v1/responses \
> >   -H "Content-Type: application/json" \
> >   -H "Authorization: Bearer $STEP_API_KEY" \
> >   -d '{
> >     "model": "step-5-preview",
> >     "input": [
> >       {
> >         "role": "user",
> >         "content": [
> >           { "type": "input_text", "text": "Summarize the main content of this video" },
> >           { "type": "input_video", "video_url": {"url": "https://example.com/demo.mp4", "detail": "low"} }
> >         ]
> >       }
> >     ]
> >   }'
> > ```

> [tab] Structured output
>
> > [tab] python
> >
> > ```python theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
> > from openai import OpenAI
> >
> > client = OpenAI(api_key="YOUR_STEP_API_KEY", base_url="https://api.stepfun.ai/v1")
> >
> > response = client.responses.create(
> >     model="step-5-preview",
> >     input="Analyze the sentiment of this sentence: This movie is fantastic, highly recommended!",
> >     text={
> >         "format": {
> >             "type": "json_schema",
> >             "name": "sentiment_analysis",
> >             "strict": True,
> >             "schema": {
> >                 "type": "object",
> >                 "properties": {
> >                     "sentiment": {"type": "string", "enum": ["positive", "negative", "neutral"]},
> >                     "confidence": {"type": "number"},
> >                     "keywords": {"type": "array", "items": {"type": "string"}},
> >                 },
> >                 "required": ["sentiment", "confidence", "keywords"],
> >                 "additionalProperties": False,
> >             },
> >         }
> >     },
> > )
> > print(response.output_text)
> > ```
>
> > [tab] js
> >
> > ```js theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
> > import OpenAI from "openai";
> >
> > const openai = new OpenAI({
> >     apiKey: "YOUR_STEP_API_KEY",
> >     baseURL: "https://api.stepfun.ai/v1"
> > });
> >
> > const response = await openai.responses.create({
> >     model: "step-5-preview",
> >     input: "Analyze the sentiment of this sentence: This movie is fantastic, highly recommended!",
> >     text: {
> >         format: {
> >             type: "json_schema",
> >             name: "sentiment_analysis",
> >             strict: true,
> >             schema: {
> >                 type: "object",
> >                 properties: {
> >                     sentiment: { type: "string", enum: ["positive", "negative", "neutral"] },
> >                     confidence: { type: "number" },
> >                     keywords: { type: "array", items: { type: "string" } }
> >                 },
> >                 required: ["sentiment", "confidence", "keywords"],
> >                 additionalProperties: false
> >             }
> >         }
> >     }
> > });
> > console.log(response.output_text);
> > ```
>
> > [tab] curl
> >
> > ```bash theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
> > curl https://api.stepfun.ai/v1/responses \
> >   -H "Content-Type: application/json" \
> >   -H "Authorization: Bearer $STEP_API_KEY" \
> >   -d '{
> >     "model": "step-5-preview",
> >     "input": "Analyze the sentiment of this sentence: This movie is fantastic, highly recommended!",
> >     "text": {
> >       "format": {
> >         "type": "json_schema",
> >         "name": "sentiment_analysis",
> >         "strict": true,
> >         "schema": {
> >           "type": "object",
> >           "properties": {
> >             "sentiment": { "type": "string", "enum": ["positive", "negative", "neutral"] },
> >             "confidence": { "type": "number" },
> >             "keywords": { "type": "array", "items": { "type": "string" } }
> >           },
> >           "required": ["sentiment", "confidence", "keywords"],
> >           "additionalProperties": false
> >         }
> >       }
> >     }
> >   }'
> > ```

> [tab] Streaming
>
> > [tab] python
> >
> > ```python theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
> > from openai import OpenAI
> >
> > client = OpenAI(api_key="YOUR_STEP_API_KEY", base_url="https://api.stepfun.ai/v1")
> >
> > stream = client.responses.create(
> >     model="step-5-preview",
> >     input="Write a haiku about spring",
> >     stream=True,
> > )
> >
> > for event in stream:
> >     if event.type == "response.output_text.delta":
> >         print(event.delta, end="", flush=True)
> > print()
> > ```
>
> > [tab] js
> >
> > ```js theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
> > import OpenAI from "openai";
> >
> > const openai = new OpenAI({
> >     apiKey: "YOUR_STEP_API_KEY",
> >     baseURL: "https://api.stepfun.ai/v1"
> > });
> >
> > const stream = await openai.responses.create({
> >     model: "step-5-preview",
> >     input: "Write a haiku about spring",
> >     stream: true
> > });
> >
> > for await (const event of stream) {
> >     if (event.type === "response.output_text.delta") {
> >         process.stdout.write(event.delta);
> >     }
> > }
> > process.stdout.write("\n");
> > ```
>
> > [tab] curl
> >
> > ```bash theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
> > curl https://api.stepfun.ai/v1/responses \
> >   -H "Content-Type: application/json" \
> >   -H "Authorization: Bearer $STEP_API_KEY" \
> >   -d '{
> >     "model": "step-5-preview",
> >     "input": "Write a haiku about spring",
> >     "stream": true
> >   }'
> > ```
>
> See the "Streaming response" section above for the streaming response format.

> [tab] Reasoning effort
>
> > [tab] python
> >
> > ```python theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
> > from openai import OpenAI
> >
> > client = OpenAI(api_key="YOUR_STEP_API_KEY", base_url="https://api.stepfun.ai/v1")
> >
> > response = client.responses.create(
> >     model="step-5-preview",
> >     input="Prove: the remainder of any perfect square modulo 4 can only be 0 or 1",
> >     reasoning={"effort": "high"},
> > )
> > print(response.output_text)
> > ```
>
> > [tab] js
> >
> > ```js theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
> > import OpenAI from "openai";
> >
> > const openai = new OpenAI({
> >     apiKey: "YOUR_STEP_API_KEY",
> >     baseURL: "https://api.stepfun.ai/v1"
> > });
> >
> > const response = await openai.responses.create({
> >     model: "step-5-preview",
> >     input: "Prove: the remainder of any perfect square modulo 4 can only be 0 or 1",
> >     reasoning: { effort: "high" }
> > });
> > console.log(response.output_text);
> > ```
>
> > [tab] curl
> >
> > ```bash theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
> > curl https://api.stepfun.ai/v1/responses \
> >   -H "Content-Type: application/json" \
> >   -H "Authorization: Bearer $STEP_API_KEY" \
> >   -d '{
> >     "model": "step-5-preview",
> >     "input": "Prove: the remainder of any perfect square modulo 4 can only be 0 or 1",
> >     "reasoning": { "effort": "high" }
> >   }'
> > ```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.