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
Rust quickstart
The siliconnetwork crate: a blocking client, Rust 1.85 or newer, with three dependencies (ureq with rustls, serde, serde_json).
1. Add the crate and set the key
The crate is not on crates.io yet. It lives in the repository at sdks/rust; depend on a checkout.
# in your project's Cargo.toml[dependencies]siliconnetwork = { path = "../siliconnetwork/sdks/rust" }# or, with access to the repository:# siliconnetwork = { git = "https://github.com/ekempinski/siliconnetwork", branch = "main" }Set SILICON_API_KEY=sn_live_... in the environment. Client::new() reads it and SILICON_BASE_URL; Client::builder() sets them, headers, retries and the timeout in code.
2. One chat completion, with errors handled
use siliconnetwork::{ChatCompletionRequest, ChatMessage, Client, Error}; fn main() -> Result<(), Error> { let client = Client::new()?; // reads SILICON_API_KEY let req = ChatCompletionRequest::new( "llama-3.2-3b", vec![ChatMessage::user("Say hello in one line.")], ); match client.chat_completion(&req) { Ok(out) => println!("{} (request {:?})", out.text(), out.meta.request_id), Err(Error::Api(e)) if e.is_out_of_credits() => eprintln!("add balance on the Billing page: {}", e.message), Err(Error::Api(e)) if e.is_rate_limited() => eprintln!("rate limited; retry after {:?}", e.retry_after), Err(Error::Api(e)) => eprintln!("{} {} (request {:?})", e.status, e.message, e.request_id), Err(e) => return Err(e), // no answer: network, TLS, timeout, or a decoding error } Ok(())}3. Stream the answer
let req = ChatCompletionRequest::new( "llama-3.2-3b", vec![ChatMessage::user("Write a haiku about silicon.")],);for chunk in client.chat_completion_stream(&req)? { if let Some(choice) = chunk?.choices.first() { print!("{}", choice.delta.content.as_deref().unwrap_or("")); }}println!();The stream also has text() and completion() for the joined text or the whole completion. Streams are not retried.
4. List the models
for model in client.list_models()?.data { println!("{} {:?}", model.id, model.aliases);}5. Errors
| Variant | When |
|---|---|
| Api(ApiError) | The gateway answered with an error status, or sent an error inside a stream: status, message, code, request_id, retry_after. |
| ComputeUnavailable(ApiError) | A compute route while no compute provider is connected. |
| Transport | No answer: connection, TLS, timeout. |
| Decode | A body could not be encoded or decoded. |
| Config | The client was set up wrong, for example no API key. |
Non-streaming calls retry 429 and 5xx twice, honoring Retry-After (at most 30 seconds); Client::builder().max_retries(..) changes that. The README in sdks/rust covers embeddings, rerank, compute and the generated route methods.