Skip to main content
LLMs know a lot, but they may lack up-to-date info (news, weather), precise calculations, or domain expertise. When they do, they might invent plausible but wrong answers. To solve this, Stepfun provides Tool Calls. Tool Calls let the model execute extra actions—search, calculations, database lookups, etc.—to return accurate information. They can also help generate function call signatures so your app can act, not just chat.

How it works

You can use Tool Calls in two ways:
  • Fetch information the model was not trained on to enrich context and answer precisely.
  • Operate local application logic to perform business actions.

Overview

The first pattern calls predefined functions to retrieve precise data. The second triggers application logic to perform tasks.

Use Tool Call to fetch information

Example: a weather skill that users access via natural language. Steps:
  • Prepare the weather API endpoint and key; implement the query function.
  • Define a get_weather tool with the function signature.
  • The model detects weather intent and fills parameters.
  • Call the weather API with those parameters and return the result.
Reference code (Python):
Response example:

Use Tool Call to perform actions

When your app needs to act (not just fetch data), Tool Calls can trigger local capabilities. Example: sending emails via natural language. Steps:
  • Implement a local email-sending function.
  • Define a send_email tool with the function signature.
  • The model detects intent and fills parameters.
  • Call the email function with those parameters.

Reference code (Python & Swift)

Local email function:
Server-side call to Stepfun:

Notes

  • Write clear function descriptions so the model understands when to call them; this improves hit rate.
  • Describe parameter fields clearly (including expected language) so the model can produce valid arguments.