StepFun chat API

Text, image understanding, function tools, streaming, and pricing for Step 3.7 Flash.

Use an Official Group API key with https://app.apipool.dev/v1 and model ID step-3.7-flash. Check availability on the model page. Sign in and choose an Official Group key to use the playground.

Text chat

curl https://app.apipool.dev/v1/chat/completions \
  -H "Authorization: Bearer $APIPOOL_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "step-3.7-flash",
    "messages": [{"role": "user", "content": "Explain vector search in one sentence."}],
    "max_tokens": 256,
    "stream": false
  }'
ParameterDescription
modelUse step-3.7-flash.
messagesArray of messages. Put text in the content string.
max_tokensMaximum output tokens for the request.
streamfalse returns JSON. true returns SSE.
stream_options.include_usageSet to true to receive final streaming usage.

Read the complete answer from choices[0].message.content. For multi-turn chat, include earlier user and assistant messages in order.

Streaming

{
  "model": "step-3.7-flash",
  "messages": [
    { "role": "user", "content": "Describe the Moon in three sentences." }
  ],
  "max_tokens": 256,
  "stream": true,
  "stream_options": { "include_usage": true }
}

Assemble choices[].delta.content and read through data: [DONE], keeping final usage. Continue reading after the first answer fragment or finish_reason. finish_reason: "length" indicates truncation.

Image understanding

Send text and an image in the same Chat Completions message.

{
  "model": "step-3.7-flash",
  "messages": [
    {
      "role": "user",
      "content": [
        { "type": "text", "text": "Describe the main colors in the image." },
        {
          "type": "image_url",
          "image_url": { "url": "data:image/png;base64,<BASE64_IMAGE>" }
        }
      ]
    }
  ],
  "max_tokens": 256,
  "stream": false
}

The response is text. The image counts toward input usage.

Function tools

Define functions in tools. Use tool_choice to select one or let the model choose.

{
  "model": "step-3.7-flash",
  "messages": [{ "role": "user", "content": "Check the weather in Hangzhou." }],
  "tools": [
    {
      "type": "function",
      "function": {
        "name": "get_weather",
        "description": "Look up the weather for a city.",
        "parameters": {
          "type": "object",
          "properties": { "city": { "type": "string" } },
          "required": ["city"]
        }
      }
    }
  ],
  "tool_choice": { "type": "function", "function": { "name": "get_weather" } },
  "max_tokens": 512,
  "stream": false
}

Read choices[0].message.tool_calls and parse the function arguments. Execute the tool in your application and verify its result. Include the assistant tool-call message and a role: "tool" message with the matching tool_call_id, then request the final answer.

Pricing and usage

Prices per million tokens are US$0.16388 for input, US$0.98328 for output, US$0.032776 for cache reads, and US$0.20485 for cache writes. Ordinary input, cache reads, and cache writes are separate. Check the active model prices before calling. Count reasoning once when the reported output includes it.

Charges use actual usage. Check Usage after calling. A retry is a new request. After a timeout or disconnect, check status and usage before retrying.

Capabilities and limits

The model supports text, image understanding, and function tools. Independent reasoning effort, video input, and built-in search are unavailable. Check the model page for context and output limits. The playground accepts up to 4,000 text characters and one PNG or JPEG up to 512 KiB. The attached image counts toward input usage. API max_tokens counts tokens.

Troubleshooting

  • HTTP 401. Verify the APIPool key.
  • HTTP 403 or an unavailable model. Check the Official Group, model status, and available balance.
  • HTTP 400. Check the model ID, message structure, and output limit. Start with the text example.
  • HTTP 429. Reduce concurrency and follow the retry information.
  • HTTP 5xx, timeout, or empty output. Save the request ID and check usage before retrying.