Skip to main content

Crate skailar

Crate skailar 

Source
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): emit tracing debug spans for requests and retries.

Modules§

client
The Skailar client: 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 ChatCompletionStream type.
types
Request and response types for every resource.

Structs§

ApiError
A structured error returned by the Skailar gateway.
ChatCompletionChunk
One event in a streamed completion.
ChatCompletionRequest
A request to create a chat completion.
ChatCompletionRequestBuilder
Builder for ChatCompletionRequest.
ChatCompletionResponse
A non-streamed chat completion.
ChatCompletionStream
An asynchronous stream of ChatCompletionChunks.
ChatMessage
A single message in a chat conversation.
Choice
One choice within a ChatCompletionResponse.
ChunkChoice
One choice within a ChatCompletionChunk.
Delta
The incremental payload of a ChunkChoice.
FunctionCall
The function invocation carried by a ToolCall.
FunctionCallDelta
Incremental function name/arguments within a ToolCallDelta.
FunctionDef
The function half of a Tool.
GeneratedImage
A single generated image.
ImageGenerationRequest
A request to generate images.
ImageGenerationRequestBuilder
Builder for ImageGenerationRequest.
ImageGenerationResponse
The response from POST /v1/images/generations.
ImageUrl
An image reference within a ContentPart::ImageUrl.
Modalities
Input/output modality lists for a Model.
Model
A model detail card as returned by retrieve.
ModelCapabilities
Capability flags for a model.
ModelList
The envelope returned by GET /v1/models.
ModelPricing
Per-token pricing for a model.
ModelSummary
A model as returned by list.
NamedFunction
The name wrapper inside a NamedToolChoice.
NamedToolChoice
A ToolChoice that pins a specific function.
PingKeyResponse
The response from GET /v1/ping-key.
ResponseMessage
The assistant message inside a Choice.
Skailar
Async client for the Skailar API.
SkailarBuilder
Builder for Skailar.
SpeechRequest
A request to create synthesized speech.
SpeechRequestBuilder
Builder for SpeechRequest.
Tool
A function-calling tool definition, OpenAI-compatible.
ToolCall
A model’s request to invoke a tool.
ToolCallDelta
An incremental tool-call fragment within a Delta.
TranscriptionRequest
A request to create a transcription.
TranscriptionRequestBuilder
Builder for TranscriptionRequest.
TranscriptionResponse
The response from POST /v1/audio/transcriptions.
UploadRequest
A request to upload a base64 payload to Skailar storage.
UploadResponse
The response from an upload endpoint.
Usage
Token accounting for a completion.

Enums§

BuildError
Error returned when a request builder is missing a required field.
ContentPart
One part of a multimodal message.
Error
Errors returned by every fallible operation in this crate.
FileContentType
Content type accepted by POST /v1/uploads/files.
FinishReason
Reason a completion stopped generating.
ImageContentType
Content type accepted by POST /v1/uploads/images.
MessageContent
The content of a ChatMessage: either plain text, a list of parts, or absent.
Mime
Audio MIME type for a transcription request.
ReasoningEffort
Reasoning budget for reasoning-capable models.
Role
Role of a chat message author.
StopSequence
A stop condition: one sequence or several.
ToolChoice
Controls whether and how the model may call tools.
Voice
A voice for speech synthesis.