Guides
- Quickstart
- Quickstarts by language
- Migration guides
- Authentication and keys
- Key protection
- Models, aliases and fallbacks
- Automatic model choice (silicon/auto)
- Chat completions
- Streaming
- Structured outputs and tools
- Logprobs
- Vision
- Responses, Claude and Ollama
- Embeddings, rerank, audio, images
- Files and batches
- Documents and search
- LoRA adapters
- Project tags and costs
- Prefix caching
- Headers, rate limits and spend caps
- Errors
- Versioning and the sandbox
- Privacy and retention
- Verifiable receipts
- Data residency
- Pricing
- Billing
- Pay per request (x402)
- On-chain oracle
- Agent credit (backed compute lines)
- Status
- SDKs
- Swift SDK
- Integrations
- Run a node
- Linux agent
- Mac mini fleets
- Compute API
- Architecture
- Changelog
- Glossary
API reference
Quickstart
Python quickstart
The siliconnetwork package: sync and async, streaming, typed with Pydantic, and its only dependencies are httpx and pydantic. Python 3.10 or newer.
1. Install and set the key
pip install siliconnetwork # not on PyPI yet? install it from the repositorypip install "git+https://github.com/ekempinski/siliconnetwork#subdirectory=sdks/python" export SILICON_API_KEY=sn_live_...Create the key on the API Keys page. The client reads SILICON_API_KEY, or takes api_key=. The package also installs the silicon command: silicon login signs it in from the browser and saves a key without printing it.
2. One chat completion
from siliconnetwork import SiliconNetwork client = SiliconNetwork() # reads SILICON_API_KEY out = client.chat.completions.create( model="llama-3.2-3b", messages=[{"role": "user", "content": "Say hello in one line."}],)print(out.choices[0].message.content)print(out.meta.request_id, out.meta.model, out.meta.node)meta carries the gateway's headers: the request id (quote it to support), the model that served and the node. Extra keyword arguments go into the body, so Silicon Network fields such as models=["fast"] (fallbacks) pass straight through.
3. Stream the answer
from siliconnetwork import SiliconNetwork client = SiliconNetwork() stream = client.chat.completions.stream( model="llama-3.2-3b", messages=[{"role": "user", "content": "Write a haiku about silicon."}],)for chunk in stream: if chunk.choices: print(chunk.choices[0].delta.content or "", end="", flush=True)print()The stream also has text() for the joined text and final() for the whole completion. AsyncSiliconNetwork has the same calls with await.
4. List the models
from siliconnetwork import SiliconNetwork client = SiliconNetwork() for model in client.models.list().data: print(model.id, model.aliases or [])The list is what the network is serving now. Any id or alias in it works as model.
5. Handle an error
from siliconnetwork import SiliconError, SiliconNetwork client = SiliconNetwork() try: out = client.chat.completions.create( model="llama-3.2-3b", messages=[{"role": "user", "content": "Say hello in one line."}], ) print(out.choices[0].message.content)except SiliconError as err: if err.is_out_of_credits: print("Add balance on the Billing page:", err) elif err.is_rate_limited: print(f"Rate limited; retry after {err.retry_after} s") else: print(err.status, err.code, err.message, err.request_id)| Field | Meaning |
|---|---|
| status | The HTTP status: 401 bad key, 402 out of credits or over a spend cap, 403 not allowed, 429 rate limited, 5xx the gateway or node failed. |
| code | The machine code, when the body carried one. |
| request_id | The gateway's request id; quote it to support. |
| retry_after | Seconds to wait, when the gateway said so. |
| is_out_of_credits, is_rate_limited | 402 and 429. |
Non-streaming calls retry 429 and 5xx twice by default, honoring Retry-After; set max_retries on the client to change that. Next: Streaming, Structured outputs and tools, Errors.