> ## 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***<br />Name of the model to use. Currently only `step-3.7-flash` is supported.
* `input` `string or object array` ***required***<br />Input content. Either a plain text string, or an ordered array of messages / events.

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

<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.
</Note>

* `instructions` `string` ***optional***<br />Top-level system instructions.
* `stream` `bool` ***optional***<br />Whether to enable SSE streaming. Default is `false`.
* `temperature` `float` ***optional***<br />Sampling temperature, between 0.0 and 2.0.
* `top_p` `float` ***optional***<br />Nucleus sampling parameter.
* `max_output_tokens` `int` ***optional***<br />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`.
</Note>

* `reasoning` `object` ***optional***<br />Reasoning configuration.

  <Expandable>
    * `effort` `string` ***optional***<br />Reasoning effort level. Valid values: `low` / `medium` / `high`.
  </Expandable>

* `tools` `object array` ***optional***<br />List of tool definitions. Currently only `function`-type tools are supported.

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

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

* `text` `object` ***optional***<br />Text output format configuration.

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

## Response Format

### Non-streaming response

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

#### Properties

* `id` `string`<br />Unique response ID, in the form `resp_xxx`.

* `object` `string`<br />Always `response`.

* `created_at` `int`<br />Creation time as a Unix timestamp (seconds).

* `completed_at` `int or null`<br />Completion time as a Unix timestamp (seconds).

* `status` `string`<br />Response status. One of `completed`, `incomplete`, or `failed`.

* `error` `object or null`<br />Error information. Non-null only when `status=failed`.

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

* `model` `string`<br />The model ID actually used.

* `output` `object array`<br />Array of output items. Each element may be of one of the following types:

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

* `usage` `object`<br />Token usage statistics.

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

* `instructions` `string or null`<br />Echoes the top-level instructions from the request.

* `max_output_tokens` `int or null`<br />Echoes the request parameter.

* `reasoning` `object or null`<br />Echoes the reasoning configuration.

* `temperature` `float or null`<br />Echoes the sampling temperature.

* `top_p` `float or null`<br />Echoes the nucleus sampling parameter.

* `text` `object`<br />Echoes the text output format configuration.

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

* `tool_choice` `string or object`<br />Echoes the tool-call strategy.

* `tools` `object array`<br />Echoes the tool definitions.

#### Example

```json theme={null}
{
  "id": "resp_xxxxxxxxxxxxxxxx",
  "object": "response",
  "created_at": 1772624997,
  "completed_at": 1772624998,
  "model": "step-3.7-flash",
  "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={null}
event: response.created
data: {"type":"response.created","sequence_number":0,"response":{"id":"resp_xxx","object":"response","created_at":1772624997,"model":"step-3.7-flash","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={null}
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

<Tabs>
  <Tab title="Basic text">
    <Tabs>
      <Tab title="python">
        ```python theme={null}
        from openai import OpenAI

        client = OpenAI(api_key="STEP_API_KEY", base_url="https://api.stepfun.ai/v1")

        response = client.responses.create(
            model="step-3.7-flash",
            input="Briefly introduce quantum computing in one sentence",
        )

        print(response.output_text)
        ```
      </Tab>

      <Tab title="js">
        ```js theme={null}
        import OpenAI from "openai";

        const openai = new OpenAI({
            apiKey: "STEP_API_KEY",
            baseURL: "https://api.stepfun.ai/v1"
        });

        const response = await openai.responses.create({
            model: "step-3.7-flash",
            input: "Briefly introduce quantum computing in one sentence",
        });

        console.log(response.output_text);
        ```
      </Tab>

      <Tab title="curl">
        ```bash theme={null}
        curl https://api.stepfun.ai/v1/responses \
          -H "Content-Type: application/json" \
          -H "Authorization: Bearer $STEP_API_KEY" \
          -d '{
            "model": "step-3.7-flash",
            "input": "Briefly introduce quantum computing in one sentence"
          }'
        ```
      </Tab>
    </Tabs>
  </Tab>

  <Tab title="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.

    <Tabs>
      <Tab title="python">
        ```python theme={null}
        from openai import OpenAI

        client = OpenAI(api_key="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-3.7-flash",
            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-3.7-flash",
            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>

      <Tab title="js">
        ```js theme={null}
        import OpenAI from "openai";

        const openai = new OpenAI({
            apiKey: "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-3.7-flash",
            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-3.7-flash",
            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>

      <Tab title="curl">
        ```bash theme={null}
        # 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-3.7-flash",
            "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-3.7-flash",
            "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>
    </Tabs>
  </Tab>

  <Tab title="Multimodal image">
    Base64 data URLs are recommended:

    <Tabs>
      <Tab title="python">
        ```python theme={null}
        import base64, requests
        from openai import OpenAI

        client = OpenAI(api_key="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-3.7-flash",
            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>

      <Tab title="js">
        ```js theme={null}
        import OpenAI from "openai";

        const openai = new OpenAI({
            apiKey: "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-3.7-flash",
            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>

      <Tab title="curl">
        ```bash theme={null}
        # 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-3.7-flash\",
            \"input\": [
              {
                \"role\": \"user\",
                \"content\": [
                  { \"type\": \"input_text\", \"text\": \"Describe the content of this image\" },
                  { \"type\": \"input_image\", \"image_url\": \"${image_base64}\" }
                ]
              }
            ]
          }"
        ```
      </Tab>
    </Tabs>

    You can also use the object form to specify `detail`:

    ```json theme={null}
    {
      "type": "input_image",
      "image_url": { "url": "data:image/jpeg;base64,...", "detail": "high" }
    }
    ```
  </Tab>

  <Tab title="Multimodal video">
    Video is passed via URL; the URL must be publicly reachable from the server:

    <Tabs>
      <Tab title="python">
        ```python theme={null}
        from openai import OpenAI

        client = OpenAI(api_key="STEP_API_KEY", base_url="https://api.stepfun.ai/v1")

        response = client.responses.create(
            model="step-3.7-flash",
            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>

      <Tab title="js">
        ```js theme={null}
        import OpenAI from "openai";

        const openai = new OpenAI({
            apiKey: "STEP_API_KEY",
            baseURL: "https://api.stepfun.ai/v1"
        });

        const response = await openai.responses.create({
            model: "step-3.7-flash",
            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>

      <Tab title="curl">
        ```bash theme={null}
        curl https://api.stepfun.ai/v1/responses \
          -H "Content-Type: application/json" \
          -H "Authorization: Bearer $STEP_API_KEY" \
          -d '{
            "model": "step-3.7-flash",
            "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>
    </Tabs>
  </Tab>

  <Tab title="Structured output">
    <Tabs>
      <Tab title="python">
        ```python theme={null}
        from openai import OpenAI

        client = OpenAI(api_key="STEP_API_KEY", base_url="https://api.stepfun.ai/v1")

        response = client.responses.create(
            model="step-3.7-flash",
            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>

      <Tab title="js">
        ```js theme={null}
        import OpenAI from "openai";

        const openai = new OpenAI({
            apiKey: "STEP_API_KEY",
            baseURL: "https://api.stepfun.ai/v1"
        });

        const response = await openai.responses.create({
            model: "step-3.7-flash",
            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>

      <Tab title="curl">
        ```bash theme={null}
        curl https://api.stepfun.ai/v1/responses \
          -H "Content-Type: application/json" \
          -H "Authorization: Bearer $STEP_API_KEY" \
          -d '{
            "model": "step-3.7-flash",
            "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>
    </Tabs>
  </Tab>

  <Tab title="Streaming">
    <Tabs>
      <Tab title="python">
        ```python theme={null}
        from openai import OpenAI

        client = OpenAI(api_key="STEP_API_KEY", base_url="https://api.stepfun.ai/v1")

        stream = client.responses.create(
            model="step-3.7-flash",
            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>

      <Tab title="js">
        ```js theme={null}
        import OpenAI from "openai";

        const openai = new OpenAI({
            apiKey: "STEP_API_KEY",
            baseURL: "https://api.stepfun.ai/v1"
        });

        const stream = await openai.responses.create({
            model: "step-3.7-flash",
            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>

      <Tab title="curl">
        ```bash theme={null}
        curl https://api.stepfun.ai/v1/responses \
          -H "Content-Type: application/json" \
          -H "Authorization: Bearer $STEP_API_KEY" \
          -d '{
            "model": "step-3.7-flash",
            "input": "Write a haiku about spring",
            "stream": true
          }'
        ```
      </Tab>
    </Tabs>

    See the "Streaming response" section above for the streaming response format.
  </Tab>

  <Tab title="Reasoning effort">
    <Tabs>
      <Tab title="python">
        ```python theme={null}
        from openai import OpenAI

        client = OpenAI(api_key="STEP_API_KEY", base_url="https://api.stepfun.ai/v1")

        response = client.responses.create(
            model="step-3.7-flash",
            input="Prove: the remainder of any perfect square modulo 4 can only be 0 or 1",
            reasoning={"effort": "high"},
        )
        print(response.output_text)
        ```
      </Tab>

      <Tab title="js">
        ```js theme={null}
        import OpenAI from "openai";

        const openai = new OpenAI({
            apiKey: "STEP_API_KEY",
            baseURL: "https://api.stepfun.ai/v1"
        });

        const response = await openai.responses.create({
            model: "step-3.7-flash",
            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>

      <Tab title="curl">
        ```bash theme={null}
        curl https://api.stepfun.ai/v1/responses \
          -H "Content-Type: application/json" \
          -H "Authorization: Bearer $STEP_API_KEY" \
          -d '{
            "model": "step-3.7-flash",
            "input": "Prove: the remainder of any perfect square modulo 4 can only be 0 or 1",
            "reasoning": { "effort": "high" }
          }'
        ```
      </Tab>
    </Tabs>
  </Tab>
</Tabs>
