Expand description
Official Rust SDK for the Skailar API.
Skailar is a multi-provider LLM gateway with an OpenAI-compatible surface.
This crate is an async-only client built on reqwest and any reqwest-
compatible async runtime (tokio recommended).
§Quickstart
use skailar::{ChatCompletionRequest, ChatMessage, Skailar};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = Skailar::new()?; // reads SKAILAR_API_KEY
let response = client
.chat()
.completions()
.create(
ChatCompletionRequest::builder()
.model("claude-sonnet-4-6")
.message(ChatMessage::user("Hello!"))
.build()?,
)
.await?;
println!("{}", response.choices[0].message.content);
Ok(())
}§Streaming
use futures_util::StreamExt;
use skailar::{ChatCompletionRequest, ChatMessage, Skailar};
let mut stream = client
.chat()
.completions()
.create_stream(
ChatCompletionRequest::builder()
.model("claude-sonnet-4-6")
.message(ChatMessage::user("Count to 5"))
.build()?,
)
.await?;
while let Some(chunk) = stream.next().await {
let chunk = chunk?;
if let Some(piece) = chunk.choices.first().and_then(|c| c.delta.content.as_deref()) {
print!("{piece}");
}
}§Authentication
Pass an API key explicitly via Skailar::builder, or set SKAILAR_API_KEY
and use Skailar::new. Keys have the form skl_live_<43 url-safe base64>
and are sent as Authorization: Bearer ….
§Errors
Every fallible call returns Error. API-level failures are carried by
Error::Api wrapping an ApiError with status-predicate helpers; see
the error module.
§Feature flags
tracing(off by default): emittracingdebug spans for requests and retries.
Modules§
- client
- The
Skailarclient: construction, configuration, and request dispatch. - error
- Error types returned across the SDK.
- models
- Known model-ID constants.
- resources
- Resource handles reachable from
Skailar. - streaming
- Server-Sent Events parsing and the
ChatCompletionStreamtype. - types
- Request and response types for every resource.
Structs§
- ApiError
- A structured error returned by the Skailar gateway.
- Chat
Completion Chunk - One event in a streamed completion.
- Chat
Completion Request - A request to
createa chat completion. - Chat
Completion Request Builder - Builder for
ChatCompletionRequest. - Chat
Completion Response - A non-streamed chat completion.
- Chat
Completion Stream - An asynchronous stream of
ChatCompletionChunks. - Chat
Message - A single message in a chat conversation.
- Choice
- One choice within a
ChatCompletionResponse. - Chunk
Choice - One choice within a
ChatCompletionChunk. - Delta
- The incremental payload of a
ChunkChoice. - Function
Call - The function invocation carried by a
ToolCall. - Function
Call Delta - Incremental function name/arguments within a
ToolCallDelta. - Function
Def - The function half of a
Tool. - Generated
Image - A single generated image.
- Image
Generation Request - A request to
generateimages. - Image
Generation Request Builder - Builder for
ImageGenerationRequest. - Image
Generation Response - The response from
POST /v1/images/generations. - Image
Url - An image reference within a
ContentPart::ImageUrl. - Modalities
- Input/output modality lists for a
Model. - Model
- A model detail card as returned by
retrieve. - Model
Capabilities - Capability flags for a model.
- Model
List - The envelope returned by
GET /v1/models. - Model
Pricing - Per-token pricing for a model.
- Model
Summary - A model as returned by
list. - Named
Function - The name wrapper inside a
NamedToolChoice. - Named
Tool Choice - A
ToolChoicethat pins a specific function. - Ping
KeyResponse - The response from
GET /v1/ping-key. - Response
Message - The assistant message inside a
Choice. - Skailar
- Async client for the Skailar API.
- Skailar
Builder - Builder for
Skailar. - Speech
Request - A request to
createsynthesized speech. - Speech
Request Builder - Builder for
SpeechRequest. - Tool
- A function-calling tool definition, OpenAI-compatible.
- Tool
Call - A model’s request to invoke a tool.
- Tool
Call Delta - An incremental tool-call fragment within a
Delta. - Transcription
Request - A request to
createa transcription. - Transcription
Request Builder - Builder for
TranscriptionRequest. - Transcription
Response - The response from
POST /v1/audio/transcriptions. - Upload
Request - A request to upload a base64 payload to Skailar storage.
- Upload
Response - The response from an upload endpoint.
- Usage
- Token accounting for a completion.
Enums§
- Build
Error - Error returned when a request builder is missing a required field.
- Content
Part - One part of a multimodal message.
- Error
- Errors returned by every fallible operation in this crate.
- File
Content Type - Content type accepted by
POST /v1/uploads/files. - Finish
Reason - Reason a completion stopped generating.
- Image
Content Type - Content type accepted by
POST /v1/uploads/images. - Message
Content - The content of a
ChatMessage: either plain text, a list of parts, or absent. - Mime
- Audio MIME type for a transcription request.
- Reasoning
Effort - Reasoning budget for reasoning-capable models.
- Role
- Role of a chat message author.
- Stop
Sequence - A stop condition: one sequence or several.
- Tool
Choice - Controls whether and how the model may call tools.
- Voice
- A voice for speech synthesis.