Siliconflow Basic
Run gpt-oss-120b on SiliconFlow with sync, streaming, and async response calls.
"""
Siliconflow Basic
=================
Cookbook example for `siliconflow/basic.py`.
"""
from agno.agent import Agent, RunOutput # noqa
from agno.models.siliconflow import Siliconflow
import asyncio
# ---------------------------------------------------------------------------
# Create Agent
# ---------------------------------------------------------------------------
agent = Agent(model=Siliconflow(id="openai/gpt-oss-120b"), markdown=True)
# Get the response in a variable
# run: RunOutput = agent.run("Explain quantum computing in simple terms")
# print(run.content)
# Print the response in the terminal
# ---------------------------------------------------------------------------
# Run Agent
# ---------------------------------------------------------------------------
if __name__ == "__main__":
# --- Sync ---
agent.print_response("Explain quantum computing in simple terms")
# --- Sync + Streaming ---
agent.print_response("Explain quantum computing in simple terms", stream=True)
# --- Async + Streaming ---
asyncio.run(agent.aprint_response("Share a 2 sentence horror story", stream=True))Run the Example
Set up your virtual environment
uv venv --python 3.12
source .venv/bin/activateInstall dependencies
uv pip install -U agno openaiExport your SiliconFlow API key
export SILICONFLOW_API_KEY="your_siliconflow_api_key_here"Select the SiliconFlow region and model
Use an API key from your global SiliconFlow account, matching the international endpoint. Add base_url="https://api.siliconflow.com/v1" to each Siliconflow(...) constructor in the saved file; the adapter default otherwise selects the .cn endpoint.
Replace the source model ID with a model enabled for your account and the example's required capabilities. For tool use, choose a currently supported function-calling model; for JSON output, check JSON mode support.
Run the example
Save the code above as basic.py, then run:
python basic.pyFull source: cookbook/90_models/siliconflow/basic.py