Stepfun-Jieyue Xingchen

Updated at:

When you want to integrate Stepfun's multimodal reasoning capabilities into your application, directly connecting to the third-party model API requires additional authentication and adaptation work. Through Model Studio's OpenAI-compatible API, you can call Stepfun models seamlessly using your existing OpenAI SDK with minimal code changes.

ImportantThis document applies only to the China (Beijing) region. To use the models, you must use an API Key from the China (Beijing) region.

Quick start

stepfun/step-3.7-flash and stepfun/step-5-preview are multimodal reasoning models directly provided by Stepfun. Thinking mode is enabled by default and cannot be disabled, so you do not need to set the enable_thinking parameter. The reasoning process of the model is returned through the reasoning_content field, and you can control the reasoning depth through the optional reasoning_effort parameter (valid values: low, medium, high). Run the following code to quickly call the model (the example uses stepfun/step-3.7-flash, which can be replaced with stepfun/step-5-preview).

You must first obtain and configure an API Key and complete configuring the API Key through environment variables. If you call the model through an SDK, you need to install the SDK.

Python

Sample code

from openai import OpenAI
import os

# Initialize the OpenAI client
client = OpenAI(
    # If the environment variable is not configured, replace it with your Alibaba Cloud Model Studio API Key: api_key="sk-xxx"
    api_key=os.getenv("DASHSCOPE_API_KEY"),
    # The following is the URL of the China (Beijing) region. Replace {WorkspaceId} with your Bailian workspace ID. URLs vary by region.
    base_url="https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/compatible-mode/v1",
)

messages = [{"role": "user", "content": "Which is greater, 9.9 or 9.11?"}]
completion = client.chat.completions.create(
    model="stepfun/step-3.7-flash",
    messages=messages,
    stream=True,
    stream_options={
        "include_usage": True
    }
)

reasoning_content = ""  # Full thinking process
answer_content = ""  # Full response
is_answering = False  # Whether the response phase has started
print("\n" + "=" * 20 + "Thinking process" + "=" * 20 + "\n")

for chunk in completion:
    if not chunk.choices:
        print("\n" + "=" * 20 + "Token usage" + "=" * 20 + "\n")
        print(chunk.usage)
        continue

    delta = chunk.choices[0].delta

    # Collect only the thinking content
    if hasattr(delta, "reasoning_content") and delta.reasoning_content is not None:
        if not is_answering:
            print(delta.reasoning_content, end="", flush=True)
        reasoning_content += delta.reasoning_content

    # Start replying when content is received
    if hasattr(delta, "content") and delta.content:
        if not is_answering:
            print("\n" + "=" * 20 + "Full response" + "=" * 20 + "\n")
            is_answering = True
        print(delta.content, end="", flush=True)
        answer_content += delta.content

Returned results

====================Thinking process====================

Okay, the user is asking which is greater, 9.9 or 9.11. First I need to compare these two decimals.
9.9 can be written as 9.90, and 9.11 stays as 9.11.
Comparing the decimal parts: 90 > 11, so 9.9 > 9.11.
====================Full response====================

9.9 is greater.

Align the decimal places: 9.9 = 9.90, and 9.11 = 9.11. Comparing the decimal parts, 0.90 > 0.11, therefore **9.9 > 9.11**.
====================Token usage====================

CompletionUsage(completion_tokens=85, prompt_tokens=10, total_tokens=95, prompt_tokens_details={'cached_tokens': 0})

Node.js

Sample code

import OpenAI from "openai";
import process from 'process';

// Initialize the OpenAI client
const openai = new OpenAI({
    // If the environment variable is not configured, replace it with your Alibaba Cloud Model Studio API Key: apiKey: "sk-xxx"
    apiKey: process.env.DASHSCOPE_API_KEY,
    // The following is the URL of the China (Beijing) region. Replace {WorkspaceId} with your Bailian workspace ID. URLs vary by region.
    baseURL: 'https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/compatible-mode/v1'
});

let reasoningContent = ''; // Full thinking process
let answerContent = ''; // Full response
let isAnswering = false; // Whether the response phase has started

async function main() {
    try {
        const messages = [{ role: 'user', content: 'Which is greater, 9.9 or 9.11?' }];

        const stream = await openai.chat.completions.create({
            model: 'stepfun/step-3.7-flash',
            messages,
            stream: true,
            stream_options: {
                include_usage: true
            }
        });

        console.log('\n' + '='.repeat(20) + 'Thinking process' + '='.repeat(20) + '\n');

        for await (const chunk of stream) {
            if (!chunk.choices?.length) {
                console.log('\n' + '='.repeat(20) + 'Token usage' + '='.repeat(20) + '\n');
                console.log(chunk.usage);
                continue;
            }

            const delta = chunk.choices[0].delta;

            // Collect only the thinking content
            if (delta.reasoning_content !== undefined && delta.reasoning_content !== null) {
                if (!isAnswering) {
                    process.stdout.write(delta.reasoning_content);
                }
                reasoningContent += delta.reasoning_content;
            }

            // Start replying when content is received
            if (delta.content !== undefined && delta.content) {
                if (!isAnswering) {
                    console.log('\n' + '='.repeat(20) + 'Full response' + '='.repeat(20) + '\n');
                    isAnswering = true;
                }
                process.stdout.write(delta.content);
                answerContent += delta.content;
            }
        }
    } catch (error) {
        console.error('Error:', error);
    }
}

main();

Returned results

====================Thinking process====================

Okay, the user is asking which is greater, 9.9 or 9.11. First I need to compare these two decimals.
9.9 can be written as 9.90, and 9.11 stays as 9.11.
Comparing the decimal parts: 90 > 11, so 9.9 > 9.11.
====================Full response====================

9.9 is greater.

Align the decimal places: 9.9 = 9.90, and 9.11 = 9.11. Comparing the decimal parts, 0.90 > 0.11, therefore **9.9 > 9.11**.
====================Token usage====================

{ prompt_tokens: 10, completion_tokens: 85, total_tokens: 95, prompt_tokens_details: { cached_tokens: 0 } }

HTTP

Sample code

curl

# The following is the URL of the China (Beijing) region. Replace {WorkspaceId} with your Bailian workspace ID. URLs vary by region.
curl -X POST https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/compatible-mode/v1/chat/completions \
-H "Authorization: Bearer $DASHSCOPE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
    "model": "stepfun/step-3.7-flash",
    "messages": [
        {
            "role": "user",
            "content": "Which is greater, 9.9 or 9.11?"
        }
    ],
    "stream": true,
    "stream_options": {
        "include_usage": true
    }
}'

Multimodal invocation examples

stepfun/step-3.7-flash not only supports pure text conversations, but also delivers multimodal understanding capabilities, supporting image and video input.

Image understanding

The image understanding feature enables the model to recognize and analyze image content. Images can be provided through a public URL or Base64 encoding. For image file limitations, see Image limitations.

Python

import os
from openai import OpenAI

client = OpenAI(
    api_key=os.getenv("DASHSCOPE_API_KEY"),
    # The following is the URL of the China (Beijing) region. Replace {WorkspaceId} with your Bailian workspace ID. URLs vary by region.
    base_url="https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/compatible-mode/v1",
)

completion = client.chat.completions.create(
    model="stepfun/step-3.7-flash",
    messages=[
        {
            "role": "user",
            "content": [
                {"type": "text", "text": "What scene is depicted in the image?"},
                {
                    "type": "image_url",
                    "image_url": {
                        "url": "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20241022/emyrja/dog_and_girl.jpeg",
                        "detail": "high"
                    }
                }
            ]
        }
    ]
)

# Print the thinking process
if hasattr(completion.choices[0].message, 'reasoning_content') and completion.choices[0].message.reasoning_content:
    print("\n" + "=" * 20 + "Thinking process" + "=" * 20 + "\n")
    print(completion.choices[0].message.reasoning_content)

# Print the response content
print("\n" + "=" * 20 + "Full response" + "=" * 20 + "\n")
print(completion.choices[0].message.content)

Node.js

import OpenAI from "openai";
import process from 'process';

const openai = new OpenAI({
    apiKey: process.env.DASHSCOPE_API_KEY,
    // The following is the URL of the China (Beijing) region. Replace {WorkspaceId} with your Bailian workspace ID. URLs vary by region.
    baseURL: 'https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/compatible-mode/v1'
});

const completion = await openai.chat.completions.create({
    model: 'stepfun/step-3.7-flash',
    messages: [
        {
            role: 'user',
            content: [
                { type: 'text', text: 'What scene is depicted in the image?' },
                {
                    type: 'image_url',
                    image_url: {
                        url: 'https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20241022/emyrja/dog_and_girl.jpeg',
                        detail: 'high'
                    }
                }
            ]
        }
    ]
});

// Print the thinking process
if (completion.choices[0].message.reasoning_content) {
    console.log('\n' + '='.repeat(20) + 'Thinking process' + '='.repeat(20) + '\n');
    console.log(completion.choices[0].message.reasoning_content);
}

// Print the response content
console.log('\n' + '='.repeat(20) + 'Full response' + '='.repeat(20) + '\n');
console.log(completion.choices[0].message.content);

HTTP

curl

# The following is the URL of the China (Beijing) region. Replace {WorkspaceId} with your Bailian workspace ID. URLs vary by region.
curl -X POST https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/compatible-mode/v1/chat/completions \
-H "Authorization: Bearer $DASHSCOPE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
    "model": "stepfun/step-3.7-flash",
    "messages": [
        {
            "role": "user",
            "content": [
                {
                    "type": "text",
                    "text": "What scene is depicted in the image?"
                },
                {
                    "type": "image_url",
                    "image_url": {
                        "url": "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20241022/emyrja/dog_and_girl.jpeg",
                        "detail": "high"
                    }
                }
            ]
        }
    ]
}'

Video understanding

The video understanding feature enables the model to recognize and analyze video content. Videos can be provided through a public URL. For video file limitations, see Video limitations.

Python

import os
from openai import OpenAI

client = OpenAI(
    api_key=os.getenv("DASHSCOPE_API_KEY"),
    # The following is the URL of the China (Beijing) region. Replace {WorkspaceId} with your Bailian workspace ID. URLs vary by region.
    base_url="https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/compatible-mode/v1",
)

completion = client.chat.completions.create(
    model="stepfun/step-3.7-flash",
    messages=[
        {
            "role": "user",
            "content": [
                {
                    "type": "video_url",
                    "video_url": {
                        "url": "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20241115/cqqkru/1.mp4"
                    }
                },
                {
                    "type": "text",
                    "text": "What is the content of this video?"
                }
            ]
        }
    ]
)

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

Node.js

import OpenAI from "openai";

const openai = new OpenAI({
    apiKey: process.env.DASHSCOPE_API_KEY,
    // The following is the URL of the China (Beijing) region. Replace {WorkspaceId} with your Bailian workspace ID. URLs vary by region.
    baseURL: "https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/compatible-mode/v1"
});

async function main() {
    const response = await openai.chat.completions.create({
        model: "stepfun/step-3.7-flash",
        messages: [
            {
                role: "user",
                content: [
                    {
                        type: "video_url",
                        video_url: {
                            url: "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20241115/cqqkru/1.mp4"
                        }
                    },
                    {
                        type: "text",
                        text: "What is the content of this video?"
                    }
                ]
            }
        ]
    });

    console.log(response.choices[0].message.content);
}

main();

HTTP

curl

# The following is the URL of the China (Beijing) region. Replace {WorkspaceId} with your Bailian workspace ID. URLs vary by region.
curl -X POST https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/compatible-mode/v1/chat/completions \
-H "Authorization: Bearer $DASHSCOPE_API_KEY" \
-H 'Content-Type: application/json' \
-d '{
    "model": "stepfun/step-3.7-flash",
    "messages": [
        {
            "role": "user",
            "content": [
                {
                    "type": "video_url",
                    "video_url": {
                        "url": "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20241115/cqqkru/1.mp4"
                    }
                },
                {
                    "type": "text",
                    "text": "What is the content of this video?"
                }
            ]
        }
    ]
}'

File limitations

Image files

  • Supported image formats: JPG/JPEG, PNG, WEBP, and static GIF
  • Single image size: no more than 10M
  • Multi-image input limit: up to 50 images per request, and the total size of all images must not exceed 20M
  • Image resolution: we recommend that the length or width not exceed 4096 pixels. The higher the resolution, the higher the model inference cost (network transfer time, time to first token, and charges increase accordingly)
  • Image input method: supports input through HTTP/HTTPS public URLs or Base64 encoding

Video files

  • Video size: up to 128M
  • Video duration: no duration limit, within 5 minutes recommended
  • Audio understanding: audio in video files is not supported for understanding

Other features

Feature

Support

Notes

Multi-turn conversation

Supported

The reasoning_content field must be retained in each assistant message. Otherwise, an error occurs.

Function Calling

Supported

Does not support the tool_choice parameter.

Context cache

Supported

Supports implicit caching. Automatically enabled.

Structured output

Supported

response_format does not support json_schema.

Web search

Not supported

—

Prefix continuation

Not supported

—

Multimodal input

Supported

Supports image (URL/Base64) and video (URL) input.

stepfun/step-3.7-flash and stepfun/step-5-preview do not support the following parameters: tool_choice, thinking_budget, top_k, modalities, repetition_penalty, vl_high_resolution_images, preserve_thinking, enable_search, search_options, seed, logprobs, top_logprobs, n.

Among the supported parameters, some parameters have value ranges and behavior that differ from Model Studio:

Parameter

Model Studio

Step

temperature

Range: [0, 2)

Range: [0, 2), default 1.0

top_p

Range: (0, 1.0]

Range: (0, 1.0], default 0.95

max_tokens

Does not limit the chain-of-thought length of thinking models. Limits only the output length.

Limits the total output length of the thinking process and the final answer.

reasoning_effort

Controls the reasoning effort of DeepSeek-V4 series models. Valid values: high/max

Valid values are low, medium, and high, used to control the reasoning depth.

stream_options

The include_usage attribute defaults to false and can be set to true

The include_usage attribute is forced to true and cannot be disabled.

detail

Not supported

Optional low/high, default low

frequency_penalty

Not supported

Range 0.0~1.0, default 0

Model list and billing

The Step series models are multimodal reasoning models directly provided by Stepfun. They support text, image, and video input, and thinking mode is enabled by default and cannot be disabled.

For model context length and pricing information, see the Model Studio console.

Billing is based on the input and output tokens of the model.

The chain of thought is billed as output tokens.

Error codes

The Step series models are directly provided by Stepfun, and their error codes differ from the standard error codes of the Model Studio platform. When calling Step models, refer to the following table.

Error code

Cause

Solution

400 - Format error

The request parameter format is incorrect. Possible causes include images that cannot be downloaded, an image count that exceeds the limit, input types not supported by the model, and invalid parameter values.

Check the request body, model capabilities, and parameter ranges.

401 - Authentication failed

The API key is missing or invalid.

Check whether the API key and request header format are correct.

402 - Insufficient balance

The account balance is insufficient.

Check the account balance and top up in time.

429 - Rate limit exceeded

Requests are too frequent and exceed the rate limit.

Implement exponential backoff and retry logic, or reduce the request frequency.

451 - Content blocked

The request content or response content failed the content review.

Modify the request content to avoid unsafe or sensitive input.

500 - Server error

An internal server failure occurred.

Retry later. If the issue persists, contact us to resolve it.

503 - Server error

The server is overloaded.

Retry later.