# Basic Usage (/docs/basic-usage) The AI SDK standardizes integrating artificial intelligence (AI) models across [supported providers](/docs/#model-providers). This enables developers to focus on building great AI applications, not waste time on technical details. For example, here’s how you can generate text with various models using the AI SDK ### Enable the [Provider](/docs/#model-providers) of your choice You can enable the provider you want by using the feature flag of the provider. e.g. for [OpenAI](/docs/providers/openai) ```bash cargo add aisdk --features openai # anthropic, google or any other provider ``` ### Generating Text To generate text, you can use the `LanguageModelRequest` builder and call the `generate_text()` method. This method returns a `GenerateTextResponse` which contains the generated text and other information such as token usage statistics, stop reason, and tool call results you can find more info about generating text [here](/docs/concepts/generating-text#generate_text). ### Streaming Text To stream text, you can use the `LanguageModelRequest` builder and call the `stream_text()` method. This method returns a `StreamTextResponse` which contains the generated text and other information such as token usage statistics, stop reason, and tool call results. You can find more info about streaming text [here](/docs/concepts/generating-text#stream_text). ## Next Steps * Take a deeper look at [`LanguageModelRequest`](/docs/concepts/generating-text) * Explore [Structured Output](/docs/concepts/structured-output) for reliable agent data. * Learn how to create [Custom Tools](/docs/concepts/tools). * Learn more about [Agents](/docs/concepts/agents). # Introduction (/docs) ## Core Features } title="Strongly Typed"> No more “model doesn’t support tool calling” errors in prod. aisdk guarantees the model fits the task at compile time. } title="Provider Agnostic"> Designed to be provider agnostic, allowing you to easily integrate with any AI provider. } title="Agents"> Build AI agents that can interact with users and perform tasks. } title="Seamless Integrations"> Seamlessly integrates with Axum, Actix and more. Compatible with Vercel's ai-sdk ui for React, Svelte, Vue and more. ## Model Providers AISDK supports a wide range of AI providers, including: * Amazon Bedrock * Anthropic * DeepSeek * Google * Groq * OpenRouter * OpenAI * Together AI * Vercel * xAI * zAI * And 65+ Other providers. See the provider docs in the navigation for the complete list. # Installation (/docs/installation) ## Installation To add the AISDK, you can use the following command: ```bash cargo add aisdk ``` This will add aisdk to your project's dependencies. ## Feature Flags `aisdk` includes several features that extend its functionality * **[Providers](/docs#model-providers)** interact with different AI model providers. ```bash cargo add aisdk --features # e.g. openai ``` * **[Prompt](/docs/concepts/prompt)** use the built-in prompt templating system. ```bash cargo add aisdk --features prompt ``` You can find more information about the available features in the API documentations. # Agents (/docs/concepts/agents) Agents are **Large Language Models (LLMs)** that use **tools** in a **loop** to accomplish complex tasks. Unlike standard generation, an agent can observe the results of its actions and decide on the next step autonomously. In AISDK, these components work together: * **LLMs**: Act as the "brain," processing input and deciding which actions to take. * **Tools**: Extend the model's capabilities (e.g., searching the web, querying a database). * **Loop**: orchestrates execution through: * **Context management** - Maintaining conversation history and deciding what the model sees at each step * **Stopping conditions** - Determining when the loop (task) is complete ## The Agentic Loop When you provide tools to a [LanguageModelRequest](/docs/concepts/generating-text), AISDK automatically manages the **Agentic Loop**. Every interaction between the model and the environment (including tool calls and intermediate reasoning) is recorded as a **Step**. A single complex request might result in multiple steps, each containing full context. 1. **Reasoning**: The model decides to call one or more tools. This triggers a new **Step**. 2. **Action**: AISDK executes the tools and captures their results. 3. **Observation**: The results are fed back into the conversation history. 4. **Re-evaluation**: The model decides the next step based on the new context. ## Example: The Weather Agent Here is a example agent that uses multiple tools to answer questions. ```rust use aisdk::core::{LanguageModelRequest, Tool, utils::step_count_is}; use aisdk::providers::OpenAI; use aisdk::macros::tool; #[tool] /// Get the current weather in a specific location fn get_weather(location: String) -> Tool { // In a real app, this would call a weather API Ok(format!("The weather in {} is 72°F and sunny.", location)) } #[tool] /// Convert Fahrenheit to Celsius fn fahrenheit_to_celsius(f: f32) -> Tool { let c = (f - 32.0) * 5.0 / 9.0; Ok(format!("{:.1}°C", c)) } #[tokio::main] async fn main() -> Result<(), Box> { let weather_agent = LanguageModelRequest::builder() .model(OpenAI::gpt_5()) .system("You are a helpful weather assistant.") .prompt("What is the weather in San Francisco in Celsius?") .with_tool(get_weather()) .with_tool(fahrenheit_to_celsius()) .stop_when(step_count_is(10)) .build() .generate_text() .await?; println!("Final Answer: {:?}", weather_agent.text()); Ok(()) } ``` ## Accessing Step Metadata You can access the history of these turns from the response. Each **Step** provides: * `step_id`: The chronological identifier of the turn. * `messages()`: All messages recorded during this specific step. * `usage()`: Token usage statistics for this turn. * `tool_calls()`: Any tools requested by the model. * `tool_results()`: Any results received from tools. ```rust for step in weather_agent.steps() { println!("--- Turn {} ---", step.step_id); println!("Messages in this turn: {} Usage: {:?}", step.messages().len(), step.usage()); } ``` ## Loop Control (`stop_when`) Because agents operate in a loop, it is critical to prevent infinite execution or excessive token usage. AISDK provides the `.stop_when()` method to define explicit exit conditions. The `stop_when` method accepts a closure with the following signature: `Fn(&LanguageModelOptions) -> bool`. This closure receives the current state of the request (including all interaction history and options) and returns `true` if the loop should terminate. ```rust /// Example: Stop when total token usage exceeds 1000: .stop_when(|options| options.usage().total_tokens > 1000) /// Example: Stop if the last assistant message contains "DONE": .stop_when(|options| { options.text().map_or(false, |t| t.contains("DONE")) }) /// Example: Stop after 5 tool calls: .stop_when(|options| { options.tool_calls().map_or(false, |calls| calls.len() > 5) }) ``` #### Using `step_count_is` Helper: The most common way to control an agent loop is by limiting the number of turns (steps). AISDK provides a `step_count_is(n)` utility for this purpose. ```rust use aisdk::core::utils::step_count_is; // Stop after 3 steps .stop_when(step_count_is(3)) ``` ## Lifecycle Hooks Hooks allow you to intercept the agent at different stages of its thinking process. This is powerful for logging, custom moderation, or dynamically adjusting the agent's context. ### `on_step_start` Runs **before** the model generates a response for a specific step. It receives a mutable reference to the current options, allowing you to modify the request context on the fly. **Signature**: `Fn(&mut LanguageModelOptions)` ```rust /// Example: Dynamically update the system prompt based on turn count: .on_step_start(|options| { let turn = options.steps().len(); if turn > 3 { options.system = Some("You are now in 'Critical Mode'. Be brief.".into()); } }) /// Example: Increase temperature as the conversation progresses: .on_step_start(|options| { let turn = options.steps().len(); options.temperature = Some(turn as u32 * 10); // Increases randomness }) ``` ### `on_step_finish` Runs **after** a model response is received but **before** tools are executed (or after the final response). It is ideal for observing the model's intent or performing safety checks. **Signature**: `Fn(&mut LanguageModelOptions)` ```rust /// Example: Log the model's intent or reasoning: .on_step_finish(|options| { if let Some(step) = options.last_step() { println!("Turn {} finished. Reasoning: {:?}", step.step_id, step.usage()); } }) /// Example: Monitor for specific tool usage: .on_step_finish(|options| { if let Some(calls) = options.tool_calls() { if calls.iter().any(|c| c.function.name == "delete_database") { println!("WARNING: Agent requested a dangerous operation!"); } } }) ``` ## Workflow Patterns While the automatic loop is powerful, many production systems require more structure. You can combine core AISDK primitives to implement advanced orchestration patterns. ### Routing Use a fast/cheap model to classify a query, then route it to a specialized agent or workflow. ```rust use schemars::JsonSchema; use serde::Deserialize; #[derive(JsonSchema, Deserialize, Debug)] enum QueryType { Technical, Billing, General, } // 1. Classify the query using Structured Output let response = LanguageModelRequest::builder() .model(OpenAI::gpt_4o_mini()) .prompt(user_query) .schema::() .build() .generate_text() .await?; let query_type: QueryType = response.into_schema().unwrap(); // 2. Route to specialized logic match query_type { QueryType::Technical => handle_technical(user_query).await?, QueryType::Billing => handle_billing(user_query).await?, QueryType::General => handle_general(user_query).await?, }; ``` ### Sequential Chains Chains execute steps in a predefined order where the output of one request becomes the input for the next. ```rust // Step 1: Generate summary let summary = LanguageModelRequest::builder() .model(OpenAI::gpt_5()) .prompt(format!("Summarize this article: {}", article)) .build() .generate_text() .await?; // Step 2: Translate the summary let translation = LanguageModelRequest::builder() .model(OpenAI::gpt_5()) .prompt(format!("Translate this to French: {:?}", summary.text())) .build() .generate_text() .await?; ``` ### Parallel Processing Execute independent tasks concurrently using `tokio::try_join!` to reduce latency. This is ideal for patterns like multi-expert reviews, where specialized models audit the same input for different concerns. ```rust use schemars::JsonSchema; use serde::Deserialize; #[derive(JsonSchema, Deserialize, Debug)] struct ReviewSummary { vulnerabilities_found: bool, performance_score: u32, action_items: Vec, } // 1. Run specialized reviews in parallel (Returning Text) let (security_res, performance_res) = tokio::try_join!( LanguageModelRequest::builder() .model(OpenAI::gpt_4o()) .system("You are a security expert.") .prompt(format!("Review this code: {}", code)) .build() .generate_text(), LanguageModelRequest::builder() .model(OpenAI::gpt_4o()) .system("You are a performance expert.") .prompt(format!("Review this code: {}", code)) .build() .generate_text() )?; // 2. Aggregate results into a Structured Report let report = LanguageModelRequest::builder() .model(OpenAI::gpt_5()) .system("You are a technical lead summarizing multiple code reviews.") .prompt(format!( "Synthesize these reviews into a structured report: \nSecurity: {:?} \nPerformance: {:?}", security_res.text(), performance_res.text() )) .schema::() .build() .generate_text() .await?; let summary: ReviewSummary = report.into_schema().unwrap(); println!("Final Structured Report: {:?}", summary); ``` ## Next Steps * Learn how to create [Custom Tools](/docs/concepts/tools). * Explore [Structured Output](/docs/concepts/structured-output) for reliable agent data. * See how [Capabilities](/docs/concepts/generating-text#capability-system) protect your agent logic. # Embedding (/docs/concepts/embedding) The `EmbeddingModelRequest` is used to embed text into vector representations using supported providers. ## Model Providers Check with the docs for the model provider of your choice to see if it supports embedding. For this example, we'll use OpenAI as our provider and the text-embedding-ada-002 model. ```bash cargo add aisdk --features openai # anthropic, google or any other provider that supports embedding. ``` At its core is the `embed()` method, which takes a `>` of text and returns a `Vec>` in which each index of the input vector corresponds to the output embeddings. ```rust let openai = OpenAI::text_embedding_ada_002(); let inputs = vec![ "Hello, world!".to_string(), "This is a test".to_string(), "Multiple embeddings".to_string(), ]; let request = EmbeddingModelRequest::builder() .model(openai) .input(inputs) .build(); .embed() .await .expect("Embedding request failed"); ``` Result will return a `Vec>` with the same length as the input vector. The output structure will be: ```rust [ [0.0012, 0.0034, 0.0056, 0.078, ...], // Example embedding for "Hello, world!" [0.01, 0.02, 0.03, 0.04, 0.05, ...], // Example embedding for "This is a test" [0.06, 0.07, 0.08, 0.09, 0.11, ...], // Example embedding for "Multiple embeddings" ] ``` # Dimensions The dimensions of the ouput embeddings can be configured with the `.dimensions(u32)` method. The default and the allowed maximum/minimum values depend on the provider so check the provider docs. in an event an unsupported value is used that causes the provider to throw an error, the sdk will propagate the error back to the user. ```rust let openai = OpenAI::text_embedding_3_small(); let request = EmbeddingModelRequest::builder() .model(openai) .input(vec!["Hello, world!".to_string()]) .dimensions(100) // Enforces a dimension of 100 .build(); .embed() .await .expect("Embedding request failed"); ``` # Generating Text (/docs/concepts/generating-text) `LanguageModelRequest` is the main AISDK interface for building and executing LLM requests. It gives you a type-safe builder, compile-time capability checks, and one consistent API across providers. ## Quick Start Pick a provider feature first (OpenAI used here): ```bash cargo add aisdk --features openai ``` Then build and run a request: ```rust use aisdk::{core::LanguageModelRequest, providers::OpenAI}; #[tokio::main] async fn main() -> Result<(), Box> { let response = LanguageModelRequest::builder() .model(OpenAI::gpt_5()) .system("You are a concise assistant.") .prompt("Explain ownership in Rust in one paragraph.") .temperature(30) .build() .generate_text() .await?; println!("{}", response.text()); Ok(()) } ``` ## The Capability System AISDK uses Rust traits to enforce model capabilities at compile time. If a model does not support a feature, the request does not compile. This applies to: * Tool calling * Structured output * Reasoning features * Multimodal input/output ```rust // ✅ WORKS: GPT-5 supports tool calls let request = LanguageModelRequest::builder() .model(OpenAI::gpt_5()) .with_tool(my_tool) // Valid! .build(); // ❌ FAILS TO COMPILE: Because O1 Mini doesn't support tool calls let request = LanguageModelRequest::builder() .model(OpenAI::o1_mini()) .with_tool(my_tool) // ERROR: The trait `ToolCallSupport` is not implemented.. .build(); ``` ## Type-State Builder Flow `LanguageModelRequest::builder()` follows a strict build sequence. Each stage only exposes valid methods for that stage. 1. Choose a model: `.model(M)` 2. Optional system instruction: `.system(...)` 3. Choose one input style: `.prompt(...)` or `.messages(...)` 4. Optional options and orchestration features 5. Finalize with `.build()` ### Request Inputs Use one of these: * `prompt(impl Into)` for a single user prompt * `messages(Messages)` for multi-turn history `prompt(...)` and `messages(...)` are mutually exclusive by design. ```rust // Single-turn let request = LanguageModelRequest::builder() .model(OpenAI::gpt_5()) .prompt("What is the capital of France?") .build(); // Multi-turn let request = LanguageModelRequest::builder() .model(OpenAI::gpt_5()) .messages(messages) .build(); ``` ### Model Options Common tuning methods: * `temperature(u32)`: randomness (0-100) * `top_p(u32)`: nucleus sampling (0-100) * `top_k(u32)`: limit token candidates * `seed(u32)`: deterministic sampling seed * `max_retries(u32)`: retry count on failures * `frequency_penalty(f32)`: repetition penalty * `stop_sequences(Vec)`: early stop tokens * `reasoning_effort(ReasoningEffort)`: reasoning level (supported models only) For `u32` percentage-style options, AISDK scales values to each provider's native format. ### Orchestration Features Use these to move from plain generation to agent workflows: * `with_tool(Tool)`: register tools (see [Tools](/docs/concepts/tools)) * `schema()`: enforce structured output (see [Structured Output](/docs/concepts/structured-output)) * `on_step_start(...)`, `on_step_finish(...)`, `stop_when(...)`: lifecycle hooks and loop control (see [Agents](/docs/concepts/agents#lifecycle-hooks)) ## Execution Build first, then execute. ### `generate_text()` Non-streaming execution. Returns when generation is complete. ```rust let response = request.generate_text().await?; println!("{}", response.text()); ``` ### `stream_text()` Streaming execution. Emits incremental chunks as tokens arrive. `LanguageModelStreamChunkType` can include: * `Start` * `Text(String)` * `Reasoning(String)` * `End(AssistantMessage)` ```rust let response = request.stream_text().await?; let mut stream = response.stream; while let Some(chunk) = stream.next().await { if let LanguageModelStreamChunkType::Text(text) = chunk { print!("{}", text); } } ``` ## Response Types Reference Both `GenerateTextResponse` and `StreamTextResponse` expose helpers for final output and execution metadata. > \[!NOTE] > On `StreamTextResponse`, metadata accessors are async and should be called after stream consumption. | Method | Description | | :--------------- | :----------------------------------------------------- | | `text()` | Text from the final assistant message | | `content()` | Final assistant content (excluding reasoning) | | `usage()` | Aggregated token usage across all steps | | `messages()` | Full conversation message history | | `stop_reason()` | Why generation ended (`Finish`, `Hook`, `Error`, etc.) | | `steps()` | All recorded steps in chronological order | | `last_step()` | Most recent step | | `step(id)` | Step lookup by ID | | `tool_calls()` | All tool calls issued during execution | | `tool_results()` | All tool results collected during execution | ### Non-Streaming Example ```rust let response = LanguageModelRequest::builder() .model(OpenAI::gpt_5()) .prompt("What is 2+2?") .build() .generate_text() .await?; println!("Text: {:?}", response.text()); println!("Usage: {:?}", response.usage()); println!("Stop Reason: {:?}", response.stop_reason()); println!("Final Content: {:?}", response.content()); ``` ### Streaming Example ```rust let response = LanguageModelRequest::builder() .model(OpenAI::gpt_5()) .prompt("Write a short story.") .build() .stream_text() .await?; let mut stream = response.stream; while let Some(chunk) = stream.next().await { if let LanguageModelStreamChunkType::Text(text) = chunk { print!("{}", text); } } // Access final metadata after stream consumption let final_usage = response.usage().await; let steps = response.steps().await; let reason = response.stop_reason().await; ``` ## Next Steps * Learn how to create [Custom Tools](/docs/concepts/tools) * Use [Structured Output](/docs/concepts/structured-output) for reliable typed data * Build multi-step workflows with [Agents](/docs/concepts/agents) # Prompts (/docs/concepts/prompts) //TODO: # Structured Output (/docs/concepts/structured-output) Structured Output allows you to force a model to output valid JSON that matches a specific schema. This is essential for building reliable applications where the model's response is consumed directly by application logic. Structured output is capability-guarded at compile time when you pick models via typed model methods (for example `OpenAI::gpt_5()`). See [Capability Safety](/docs/concepts/generating-text#the-capability-system) in the Generating Text docs. ## Getting Started AISDK relies on the `serde` and `schemars` crates to convert rust structs into JSON and vice versa. Add them to your Cargo.toml to enable structured output. ```bash cargo add serde schemars ``` ### Defining a Schema Define your target data structures using simple patterns, such as `#[derive(JsonSchema, Deserialize)]`.: ```rust use schemars::JsonSchema; use serde::Deserialize; #[derive(JsonSchema, Deserialize, Debug)] struct UserInfo { name: String, age: u32, email: Option, } ``` ## Example: Information Extraction Here is how to extract structured data from a block of text. ```rust use aisdk::core::LanguageModelRequest; use aisdk::providers::OpenAI; #[tokio::main] async fn main() -> Result<(), Box> { let input = "My name is Alice, I am 28 years old and you can reach me at alice@example.com"; let response = LanguageModelRequest::builder() .model(OpenAI::gpt_5()) .prompt(format!("Extract information from: {}", input)) .schema::() // Tell the model what structure you expect .build() .generate_text() .await?; // Deserialize the response into your struct let user: UserInfo = response.into_schema()?; println!("Name: {}", user.name); println!("Age: {}", user.age); println!("Email: {}", user.email.unwrap_or_default()); Ok(()) } ``` ## Advanced Schemas You can use complex Rust types to define sophisticated schemas. ### Enums for Classification Enums are perfect for categorizing input into a fixed set of options. ```rust #[derive(JsonSchema, Deserialize, Debug)] enum Sentiment { Positive, Negative, Neutral, } #[derive(JsonSchema, Deserialize, Debug)] struct SentimentAnalysis { sentiment: Sentiment, confidence: f32, // 0.0 to 1.0 } ``` ### Nested Objects and Lists You can nest structs and use `Vec` to represent complex heirarchies. ```rust #[derive(JsonSchema, Deserialize, Debug)] struct Recipe { name: String, ingredients: Vec, prep_time_minutes: u32, } #[derive(JsonSchema, Deserialize, Debug)] struct Ingredient { item: String, amount: String, } ``` *** ## Next Steps * Explore creating [Custom Tools](/docs/concepts/tools). * Learn how [Agents](/docs/concepts/agents) use Structured Output for routing. * See the full [Language Model Request](/docs/concepts/generating-text) documentation. # Tools (/docs/concepts/tools) While large language models (LLMs) have incredible generation capabilities, they struggle with discrete tasks (e.g. mathematics) and interacting with the outside world (e.g. getting the weather). A 'Tool' is a general term for a function or logic that can be executed by an AI model. They can be user defined or pre-defined by the provider. Tools are provided to the AI model's context as per the developer's needs.The AI model can then use the provided tools to perform specific queries to aid in text generation or actions to be taken externally. Tool usage is capability-guarded at compile time when you pick models via typed model methods (for example `OpenAI::gpt_5()`). See [Capability Safety](/docs/concepts/generating-text#the-capability-system) in the Generating Text docs. ## Defining Tools with `#[tool]` The recommended way to define tools is using the `#[tool]` macro. This attribute transforms a standard Rust function into a `Tool` object that the model can understand. ```rust use aisdk::core::Tool; use aisdk::macros::tool; #[tool] /// Get the current weather in a specific location pub fn get_weather(location: String) -> Tool { // In a real app, this would call a weather API let weather = format!("The weather in {} is 75°F and sunny.", location); Ok(weather) } ``` ### Function-to-Tool Extraction AISDK automatically extracts metadata from your function: * **Name**: Unique, descriptive name of the tool. Her it is automatically inferred as `get_weather` from the function name. * **Description**: Briefly describes the tool's purpose and usage. Rust-style docs with examples can be used for few-shot prompting. * **Arguments**: Function parameters are automatically converted into a JSON Schema using `schemars`. * **Body**: The tool’s logic executed when called by the AI. Must return `Tool` or `Result`. Errors can be returned as `Err(String)` to help the AI understand failures. ### Registering Tools To make a tool available to a model, pass it to the `.with_tool()` method in the [`LanguageModelRequest`](/docs/concepts/generating-text) builder. > When using the `#[tool]` macro, the macro wraps your logic in a function that returns a `Tool`. You must **call** the function (e.g., `get_weather()`) when passing it to the builder. This appends the tool to the list of tools that the AI model will use. ```rust let response = LanguageModelRequest::builder() .model(OpenAI::gpt_5()) .prompt("What's the weather in Tokyo?") .with_tool(get_weather()) // Register the tool .build() .generate_text() .await?; ``` ### `tool` Macro Customization You can override the default inferred name and description using macro attributes. ```rust #[tool(name = "check-weather", desc = "Retrieves weather data for a city")] fn get_weather(location: String) -> Tool { Ok(format!("Sunny in {}", location)) } ``` ## Manual Tool Definition (Advanced) You can define your own tools in aisdk by instantiating the `Tool` and related structs and passing it to one of the AI model text generation builders. ### Defining the Tool ````rust use super::{Tool, ToolExecute}; use serde_json::Value; // define tool function body, should return Result #[allow(unused_variables)] let func = ToolExecute::new(Box::new(|inp: Value| { // Ai SDK will pass in a json object with the following structure // ```json // { // "location": "New York" // } // ``` let location = inp.get("location").unwrap(); Ok(format!("Cloudy")) })); // define tool input structure #[derive(schemars::JsonSchema, Debug)] #[allow(dead_code)] struct ToolInput { location: String, } // change tool arguments to json schema // Which will be similar to the following // ```json // "properties": { // "location": { // "type": "string" // } // } let schema = schemars::schema_for!(ToolInput); // bring it all together let get_weather_tool = Tool::builder() .name("get-weather") .description("Get the weather information given a location") .input_schema(schema.clone()) .execute(func) .build() .unwrap(); ```` ### Registering Manually-Defined Tools To register manually-defined tools with the AI model, you need to add them to [`LanguageModelRequest`](/docs/concepts/generating-text) builder using the `with_tool` method. This appends the tool to the list of tools that the AI model will use. ```rust // call the model with `Tool` struct let result = LanguageModelRequest::builder() .model(OpenAI::new("gpt-4o")) .system("You are a helpful assistant with access to tools.") .prompt("What is the weather in New York?") .with_tool(get_weather_tool) // you don't need to call it if using structs. .build() .generate_text() .await; ``` ## Next Steps * Use tools in a loop with [Agents](/docs/concepts/agents). * Learn how to extract [Structured Output](/docs/concepts/structured-output). * Explore the full [Language Model Request](/docs/concepts/generating-text) API. # Axum (/docs/integrations/axum) The Axum integration provides seamless support for building AI-powered web applications with `aisdk` and Axum web framework. It handles server-sent events (SSE) streaming, enabling real-time delivery of AI-generated content to frontend clients. ## Installation Add the `axum` feature to enable Axum-specific integrations: ```bash cargo add aisdk --features axum ``` Additional dependencies for the Axum web server: ```bash cargo add axum tower-http --features tower-http/cors ``` ## Vercel AI SDK UI AISDK.rs Axum integration includes built-in support for [Vercel's AI SDK UI](https://ai-sdk.dev/docs/ai-sdk-ui/overview). The integration automatically converts [`StreamTextResponse`](/docs/ai-sdk-ui/overview) to Axum SSE responses in Vercel-compatible format, allowing you to use frontend hooks like `useChat` and `useCompletion` with minimal setup. ### How It Works 1. **Request**: Frontend sends `VercelUIRequest` using Vercel's AI SDK UI hooks such as `useChat` via SSE 2. **Processing**: AISDK.rs processes the request with [`LanguageModelRequest`](/docs/concepts/generating-text) Streaming API 3. **Conversion**: Response is automatically converted to Vercel UI stream chunks 4. **Response**: Axum streams the chunks back to the frontend ### Quick Example ```rust use aisdk::{ core::LanguageModelRequest, integrations::{ axum::AxumSseResponse, vercel_aisdk_ui::VercelUIRequest, }, providers::OpenAI, }; // Example handler function async fn chat_handler( axum::Json(request): axum::Json, ) -> AxumSseResponse { // Convert the Message sent by the frontend to AISDK.rs Messages let messages = request.into(); // Generate streaming response let response = LanguageModelRequest::builder() .model(OpenAI::gpt_4o()) .messages(messages) .build() .stream_text() .await .unwrap(); // Convert to Axum SSE response (Vercel UI compatible) response.into() } #[tokio::main] async fn main() { let app = axum::Router::new() .route("/api/chat", axum::routing::post(chat_handler)) .layer(tower_http::cors::CorsLayer::permissive()); let addr = std::net::SocketAddr::from(([127, 0, 0, 1], 8080)); println!("Listening on http://{}", addr); let listener = tokio::net::TcpListener::bind(addr).await.unwrap(); axum::serve(listener, app).await.unwrap(); } ``` > **Note**: `AxumSseResponse` is a type alias for `axum::response::Sse>>`. You can replace `AxumSseResponse` with the full type definition if you prefer. ### Frontend Example (React) This example uses React, but you can use any Vercel AI SDK UI supported frontend framework such as React, Vue.js, Svelte, Angular, or SolidJS. See the [complete list of supported frameworks](https://ai-sdk.dev/docs/ai-sdk-ui/overview#ui-framework-support). ```tsx 'use client'; import { useChat } from '@ai-sdk/react'; import { DefaultChatTransport } from 'ai'; import { useState } from 'react'; export default function Page() { const { messages, sendMessage, status } = useChat({ transport: new DefaultChatTransport({ api: 'http://localhost:8080/api/chat', }), }); const [input, setInput] = useState(''); return ( <> {messages.map(message => (
{message.role === 'user' ? 'User: ' : 'AI: '} {message.parts.map((part, index) => part.type === 'text' ? {part.text} : null, )}
))}
{ e.preventDefault(); if (input.trim()) { sendMessage({ text: input }); setInput(''); } }} > setInput(e.target.value)} disabled={status !== 'ready'} placeholder="Say something..." />
); } ``` ### Builder Configuration For more control over streaming behavior, use the builder API to configure which chunk types to send: ```rust use aisdk::core::LanguageModelRequest; use aisdk::integrations::vercel_aisdk_ui::VercelUIRequest; use aisdk::integrations::axum::AxumSseResponse; use aisdk::providers::OpenAI; async fn chat_handler( Json(request): Json, ) -> AxumSseResponse { let messages = request.into(); let response = LanguageModelRequest::builder() .model(OpenAI::gpt_4o()) .messages(messages) .build() .stream_text() .await?; // Configure stream with builder response .to_axum_vercel_ui_stream() .send_reasoning() // Enable reasoning chunks .send_start() // Include start signals .send_finish() // Include finish signals .build() } ``` #### Builder Options | Method | Description | | ----------------------- | ---------------------------------------- | | `send_reasoning()` | Include reasoning chunks in the stream | | `send_start()` | Send start signal chunks | | `send_finish()` | Send finish signal chunks | | `with_id_generator(fn)` | Set custom message ID generator function | | `build()` | Build the final `AxumSseResponse` | ## Next Steps * Read the [Vercel AI SDK UI docs](https://ai-sdk.dev/docs/ai-sdk-ui/overview) for frontend details * Take a deeper look at [`LanguageModelRequest`](/docs/concepts/generating-text) * Learn how to create [Custom Tools](/docs/concepts/tools). * Learn more about [Agents](/docs/concepts/agents). # Vercel AI-SDK UI (/docs/integrations) The Vercel AI SDK UI integration allows you to build **Rust backends** that work seamlessly with [Vercel's AI SDK UI frontend hooks](https://ai-sdk.dev/docs/ai-sdk-ui/overview). It converts AISDK.rs streams into the Vercel-compatible SSE format, enabling you to use `useChat`, `useCompletion`, and other frontend hooks with a Rust backend. ## How It Works ``` Frontend (useChat) → SSE → Rust Backend (AISDK.rs) ↓ VercelUIStream chunks ``` ## Quick Start AISDK.rs provides framework support for Rust backends with seamless integration. In this example, we'll use **Axum** for the Rust backend and **React** for the frontend. However, you can use [other supported Rust backends](#backend-framework-supports) with AISDK.rs. Similarly, Vercel's AI SDK UI supports many frontend frameworks, so you can choose the one that works best for your project. See the [list of supported frontend frameworks](https://ai-sdk.dev/docs/ai-sdk-ui/overview#ui-framework-support). ### Install Dependencies Since we're using Axum, you need to enable the `axum` feature in AISDK. For the AI provider, we're using OpenAI, but you can use [any available provider](/docs#model-providers). ```bash cargo add aisdk --features openai axum ``` ### Backend Example (Axum) ```rust use aisdk::{ core::LanguageModelRequest, integrations::{ axum::AxumSseResponse, vercel_aisdk_ui::VercelUIRequest, }, providers::OpenAI, }; // Example Axum handler function async fn chat_handler( axum::Json(request): axum::Json, ) -> AxumSseResponse { // Convert the Message sent by the frontend to AISDK.rs Messages let messages = request.into(); // Generate streaming response let response = LanguageModelRequest::builder() .model(OpenAI::gpt_4o()) .messages(messages) .build() .stream_text() .await?; // Convert to Axum SSE response (Vercel UI compatible) response.into() } ``` For more information, see the [Axum integration docs](/docs/integrations/axum#vercel-ai-sdk-ui). ### Frontend Example (React) This example uses React, but you can use any Vercel AI SDK UI supported frontend framework such as React, Vue.js, Svelte, Angular, or SolidJS. See the [complete list of supported frameworks](https://ai-sdk.dev/docs/ai-sdk-ui/overview#ui-framework-support). ```tsx 'use client'; import { useChat } from '@ai-sdk/react'; import { DefaultChatTransport } from 'ai'; import { useState } from 'react'; export default function Page() { const { messages, sendMessage, status } = useChat({ transport: new DefaultChatTransport({ api: 'http://localhost:8080/api/chat', }), }); const [input, setInput] = useState(''); return ( <> {messages.map(message => (
{message.role === 'user' ? 'User: ' : 'AI: '} {message.parts.map((part, index) => part.type === 'text' ? {part.text} : null, )}
))}
{ e.preventDefault(); if (input.trim()) { sendMessage({ text: input }); setInput(''); } }} > setInput(e.target.value)} disabled={status !== 'ready'} placeholder="Say something..." />
); } ``` ## Backend Framework Supports AISDK.rs provides seamless integration for receiving requests from Vercel's AI SDK UI frontend hooks, processing them with the [`LanguageModelRequest`](/docs/concepts/generating-text) API, and streaming responses back in the Vercel-compatible format. This integration handles all of the low-level details of SSE streaming and message format conversion. Currently supported frameworks: * [Axum](/docs/integrations/axum#vercel-ai-sdk-ui) More frameworks will be added in the future. ### Manual Conversion If you need full control over the request handling and streaming process, or if your framework isn't yet supported by AISDK.rs, you can use the manual conversion approach. This gives you complete flexibility to integrate with any web framework. Use the `into_vercel_ui_stream()` method to convert a `StreamTextResponse` into Vercel UI stream chunk types. You can configure which chunk types to send (reasoning, start, finish) using `VercelUIStreamOptions`. ```rust use aisdk::core::{LanguageModelRequest, Messages}; use aisdk::integrations::vercel_aisdk_ui::{VercelUIRequest, VercelUIStreamOptions}; use aisdk::providers::OpenAI; use futures::Stream; // Handler function signature varies by your framework async fn chat_handler(request: impl Into) -> impl Stream> { // Extract VercelUIRequest from the framework-specific request let ui_message: VercelUIRequest = request.into(); // Convert VercelUIRequest to AISDK Messages let messages: Messages = ui_message.into(); // Generate streaming response let response = LanguageModelRequest::builder() .model(OpenAI::gpt_3_5_turbo()) .messages(messages) .build() .stream_text() .await?; // Configure which chunk types to send let options = VercelUIStreamOptions { send_reasoning: true, send_start: true, send_finish: true, generate_message_id: None, }; // Convert LanguageModelStream to VercelUIStream let vercel_stream = response.into_vercel_ui_stream(options); // Return the stream using your framework's specific response type // This is framework-specific - see Axum integration for a complete example vercel_stream } ``` ## Next Steps * Read the [Vercel AI SDK UI docs](https://ai-sdk.dev/docs/ai-sdk-ui/overview) for frontend details * Take a deeper look at [`LanguageModelRequest`](/docs/concepts/generating-text) * Learn how to create [Custom Tools](/docs/concepts/tools). * Learn more about [Agents](/docs/concepts/agents). # Ai302 (/docs/providers/302ai) AISDK provides first-class support for Ai302 with fully typed model APIs. Model capabilities are enforced at compile time using Rust's type system. This prevents model capability mismatches and guarantees the selected model is valid for the task (e.g. tool calling). ## Installation Enable the Ai302 provider feature: ```bash cargo add aisdk --features 302ai ``` This installs AISDK with the Ai302 provider enabled. Once you have enabled the Ai302 provider, you can use all aisdk features with it. ## Create a Provider Instance To create a provider instance, call `Ai302::model_name()`, where **model\_name** is the Ai302 model you want to use. Model names are exposed as snake-case methods. ```rust use aisdk::providers::Ai302; let 302ai = Ai302::minimax_m1(); ``` This initializes the provider with: * Model: `"MiniMax-M1"` * API key from environment (if set with `302AI_API_KEY`) * Ai302's default base URL ([https://api.302.ai/v1](https://api.302.ai/v1)) ## Basic Text Generation Example using [LanguageModelRequest](https://docs.rs/aisdk/latest/aisdk/core/struct.LanguageModelRequest.html) for text generation. ```rust use aisdk::{ core::LanguageModelRequest, providers::Ai302, }; #[tokio::main] async fn main() -> Result<(), Box> { let 302ai = Ai302::minimax_m1(); let response = LanguageModelRequest::builder() .model(302ai) .prompt("Write a short poem about Rust.") .build() .generate_text() .await?; println!("Response text: {:?}", response.text()); Ok(()) } ``` ## Provider Settings You can customize provider configuration using `Ai302::builder()` ### API Key ```rust let 302ai = Ai302::::builder() .api_key("your-api-key") .build()?; ``` If not specified, AISDK uses the `302AI_API_KEY` environment variable. ### Base URL Useful when routing through a proxy, gateway, or self-hosted compatible endpoint. ```rust let 302ai = Ai302::::builder() .base_url("https://api.302.ai/v1") .build()?; ``` ### Path (Full URL Override) Use `.path(...)` to override the full request URL instead of only the base URL. ```rust let 302ai = Ai302::::builder() .path("https://full-url.example/v1/chat/completions") .build()?; ``` ### Provider Name For logging, analytics, and observability. ```rust let 302ai = Ai302::::builder() .provider_name("Ai302") .build()?; ``` ### Full Custom Configuration Example ```rust let 302ai = Ai302::::builder() .api_key("your-api-key") .base_url("https://api.302.ai/v1") .path("https://full-url.example/v1/chat/completions") .provider_name("Ai302") .build()?; ``` ## Dynamic Model Selection For runtime model selection (e.g., loading models from config files), use `DynamicModel`: ### Using model\_name() Method with Default Settings ```rust use aisdk::providers::Ai302; // Specify model as a string at runtime let 302ai = Ai302::model_name("MiniMax-M1"); ``` ### Using Builder Pattern with Custom Settings ```rust use aisdk::{ core::DynamicModel, providers::Ai302, }; let 302ai = Ai302::::builder() .model_name("MiniMax-M1") .api_key("your-api-key") .base_url("https://api.302.ai/v1") .path("https://full-url.example/v1/chat/completions") .provider_name("Ai302") .build()?; ``` **Warning**: When using `DynamicModel`, model capabilities are **not validated at compile time**. This means there's no guarantee the model supports requested features (e.g., tool calls, structured output). For compile-time safety, use the typed methods like `Ai302::minimax_m1()`. ## Next Steps * Take a deeper look at text generation features [Generating Text](/docs/concepts/generating-text#generate_text) / [Streaming Text](/docs/concepts/generating-text#stream_text) * Explore [Structured Output](/docs/concepts/structured-output) for reliable agent data. * Learn how to create [Custom Tools](/docs/concepts/tools). * Learn more about [Agents](/docs/concepts/agents). # Abacus (/docs/providers/abacus) AISDK provides first-class support for Abacus with fully typed model APIs. Model capabilities are enforced at compile time using Rust's type system. This prevents model capability mismatches and guarantees the selected model is valid for the task (e.g. tool calling). ## Installation Enable the Abacus provider feature: ```bash cargo add aisdk --features abacus ``` This installs AISDK with the Abacus provider enabled. Once you have enabled the Abacus provider, you can use all aisdk features with it. ## Create a Provider Instance To create a provider instance, call `Abacus::model_name()`, where **model\_name** is the Abacus model you want to use. Model names are exposed as snake-case methods. ```rust use aisdk::providers::Abacus; let abacus = Abacus::qwen_qwq_32b(); ``` This initializes the provider with: * Model: `"Qwen/QwQ-32B"` * API key from environment (if set with `ABACUS_API_KEY`) * Abacus's default base URL ([https://routellm.abacus.ai/v1](https://routellm.abacus.ai/v1)) ## Basic Text Generation Example using [LanguageModelRequest](https://docs.rs/aisdk/latest/aisdk/core/struct.LanguageModelRequest.html) for text generation. ```rust use aisdk::{ core::LanguageModelRequest, providers::Abacus, }; #[tokio::main] async fn main() -> Result<(), Box> { let abacus = Abacus::qwen_qwq_32b(); let response = LanguageModelRequest::builder() .model(abacus) .prompt("Write a short poem about Rust.") .build() .generate_text() .await?; println!("Response text: {:?}", response.text()); Ok(()) } ``` ## Provider Settings You can customize provider configuration using `Abacus::builder()` ### API Key ```rust let abacus = Abacus::::builder() .api_key("your-api-key") .build()?; ``` If not specified, AISDK uses the `ABACUS_API_KEY` environment variable. ### Base URL Useful when routing through a proxy, gateway, or self-hosted compatible endpoint. ```rust let abacus = Abacus::::builder() .base_url("https://routellm.abacus.ai/v1") .build()?; ``` ### Path (Full URL Override) Use `.path(...)` to override the full request URL instead of only the base URL. ```rust let abacus = Abacus::::builder() .path("https://full-url.example/v1/chat/completions") .build()?; ``` ### Provider Name For logging, analytics, and observability. ```rust let abacus = Abacus::::builder() .provider_name("Abacus") .build()?; ``` ### Full Custom Configuration Example ```rust let abacus = Abacus::::builder() .api_key("your-api-key") .base_url("https://routellm.abacus.ai/v1") .path("https://full-url.example/v1/chat/completions") .provider_name("Abacus") .build()?; ``` ## Dynamic Model Selection For runtime model selection (e.g., loading models from config files), use `DynamicModel`: ### Using model\_name() Method with Default Settings ```rust use aisdk::providers::Abacus; // Specify model as a string at runtime let abacus = Abacus::model_name("Qwen/QwQ-32B"); ``` ### Using Builder Pattern with Custom Settings ```rust use aisdk::{ core::DynamicModel, providers::Abacus, }; let abacus = Abacus::::builder() .model_name("Qwen/QwQ-32B") .api_key("your-api-key") .base_url("https://routellm.abacus.ai/v1") .path("https://full-url.example/v1/chat/completions") .provider_name("Abacus") .build()?; ``` **Warning**: When using `DynamicModel`, model capabilities are **not validated at compile time**. This means there's no guarantee the model supports requested features (e.g., tool calls, structured output). For compile-time safety, use the typed methods like `Abacus::qwen_qwq_32b()`. ## Next Steps * Take a deeper look at text generation features [Generating Text](/docs/concepts/generating-text#generate_text) / [Streaming Text](/docs/concepts/generating-text#stream_text) * Explore [Structured Output](/docs/concepts/structured-output) for reliable agent data. * Learn how to create [Custom Tools](/docs/concepts/tools). * Learn more about [Agents](/docs/concepts/agents). # Aihubmix (/docs/providers/aihubmix) AISDK provides first-class support for Aihubmix with fully typed model APIs. Model capabilities are enforced at compile time using Rust's type system. This prevents model capability mismatches and guarantees the selected model is valid for the task (e.g. tool calling). ## Installation Enable the Aihubmix provider feature: ```bash cargo add aisdk --features aihubmix ``` This installs AISDK with the Aihubmix provider enabled. Once you have enabled the Aihubmix provider, you can use all aisdk features with it. ## Create a Provider Instance To create a provider instance, call `Aihubmix::model_name()`, where **model\_name** is the Aihubmix model you want to use. Model names are exposed as snake-case methods. ```rust use aisdk::providers::Aihubmix; let aihubmix = Aihubmix::kimi_k2_0905(); ``` This initializes the provider with: * Model: `"Kimi-K2-0905"` * API key from environment (if set with `AIHUBMIX_API_KEY`) * Aihubmix's default base URL ([https://aihubmix.com/v1](https://aihubmix.com/v1)) ## Basic Text Generation Example using [LanguageModelRequest](https://docs.rs/aisdk/latest/aisdk/core/struct.LanguageModelRequest.html) for text generation. ```rust use aisdk::{ core::LanguageModelRequest, providers::Aihubmix, }; #[tokio::main] async fn main() -> Result<(), Box> { let aihubmix = Aihubmix::kimi_k2_0905(); let response = LanguageModelRequest::builder() .model(aihubmix) .prompt("Write a short poem about Rust.") .build() .generate_text() .await?; println!("Response text: {:?}", response.text()); Ok(()) } ``` ## Provider Settings You can customize provider configuration using `Aihubmix::builder()` ### API Key ```rust let aihubmix = Aihubmix::::builder() .api_key("your-api-key") .build()?; ``` If not specified, AISDK uses the `AIHUBMIX_API_KEY` environment variable. ### Base URL Useful when routing through a proxy, gateway, or self-hosted compatible endpoint. ```rust let aihubmix = Aihubmix::::builder() .base_url("https://aihubmix.com/v1") .build()?; ``` ### Path (Full URL Override) Use `.path(...)` to override the full request URL instead of only the base URL. ```rust let aihubmix = Aihubmix::::builder() .path("https://full-url.example/v1/chat/completions") .build()?; ``` ### Provider Name For logging, analytics, and observability. ```rust let aihubmix = Aihubmix::::builder() .provider_name("Aihubmix") .build()?; ``` ### Full Custom Configuration Example ```rust let aihubmix = Aihubmix::::builder() .api_key("your-api-key") .base_url("https://aihubmix.com/v1") .path("https://full-url.example/v1/chat/completions") .provider_name("Aihubmix") .build()?; ``` ## Dynamic Model Selection For runtime model selection (e.g., loading models from config files), use `DynamicModel`: ### Using model\_name() Method with Default Settings ```rust use aisdk::providers::Aihubmix; // Specify model as a string at runtime let aihubmix = Aihubmix::model_name("Kimi-K2-0905"); ``` ### Using Builder Pattern with Custom Settings ```rust use aisdk::{ core::DynamicModel, providers::Aihubmix, }; let aihubmix = Aihubmix::::builder() .model_name("Kimi-K2-0905") .api_key("your-api-key") .base_url("https://aihubmix.com/v1") .path("https://full-url.example/v1/chat/completions") .provider_name("Aihubmix") .build()?; ``` **Warning**: When using `DynamicModel`, model capabilities are **not validated at compile time**. This means there's no guarantee the model supports requested features (e.g., tool calls, structured output). For compile-time safety, use the typed methods like `Aihubmix::kimi_k2_0905()`. ## Next Steps * Take a deeper look at text generation features [Generating Text](/docs/concepts/generating-text#generate_text) / [Streaming Text](/docs/concepts/generating-text#stream_text) * Explore [Structured Output](/docs/concepts/structured-output) for reliable agent data. * Learn how to create [Custom Tools](/docs/concepts/tools). * Learn more about [Agents](/docs/concepts/agents). # AlibabaCn (/docs/providers/alibaba-cn) AISDK provides first-class support for AlibabaCn with fully typed model APIs. Model capabilities are enforced at compile time using Rust's type system. This prevents model capability mismatches and guarantees the selected model is valid for the task (e.g. tool calling). ## Installation Enable the AlibabaCn provider feature: ```bash cargo add aisdk --features alibaba-cn ``` This installs AISDK with the AlibabaCn provider enabled. Once you have enabled the AlibabaCn provider, you can use all aisdk features with it. ## Create a Provider Instance To create a provider instance, call `AlibabaCn::model_name()`, where **model\_name** is the AlibabaCn model you want to use. Model names are exposed as snake-case methods. ```rust use aisdk::providers::AlibabaCn; let alibaba-cn = AlibabaCn::deepseek_r1(); ``` This initializes the provider with: * Model: `"deepseek-r1"` * API key from environment (if set with `DASHSCOPE_API_KEY`) * AlibabaCn's default base URL ([https://dashscope.aliyuncs.com/compatible-mode/v1](https://dashscope.aliyuncs.com/compatible-mode/v1)) ## Basic Text Generation Example using [LanguageModelRequest](https://docs.rs/aisdk/latest/aisdk/core/struct.LanguageModelRequest.html) for text generation. ```rust use aisdk::{ core::LanguageModelRequest, providers::AlibabaCn, }; #[tokio::main] async fn main() -> Result<(), Box> { let alibaba-cn = AlibabaCn::deepseek_r1(); let response = LanguageModelRequest::builder() .model(alibaba-cn) .prompt("Write a short poem about Rust.") .build() .generate_text() .await?; println!("Response text: {:?}", response.text()); Ok(()) } ``` ## Provider Settings You can customize provider configuration using `AlibabaCn::builder()` ### API Key ```rust let alibaba-cn = AlibabaCn::::builder() .api_key("your-api-key") .build()?; ``` If not specified, AISDK uses the `DASHSCOPE_API_KEY` environment variable. ### Base URL Useful when routing through a proxy, gateway, or self-hosted compatible endpoint. ```rust let alibaba-cn = AlibabaCn::::builder() .base_url("https://dashscope.aliyuncs.com/compatible-mode/v1") .build()?; ``` ### Path (Full URL Override) Use `.path(...)` to override the full request URL instead of only the base URL. ```rust let alibaba-cn = AlibabaCn::::builder() .path("https://full-url.example/v1/chat/completions") .build()?; ``` ### Provider Name For logging, analytics, and observability. ```rust let alibaba-cn = AlibabaCn::::builder() .provider_name("AlibabaCn") .build()?; ``` ### Full Custom Configuration Example ```rust let alibaba-cn = AlibabaCn::::builder() .api_key("your-api-key") .base_url("https://dashscope.aliyuncs.com/compatible-mode/v1") .path("https://full-url.example/v1/chat/completions") .provider_name("AlibabaCn") .build()?; ``` ## Dynamic Model Selection For runtime model selection (e.g., loading models from config files), use `DynamicModel`: ### Using model\_name() Method with Default Settings ```rust use aisdk::providers::AlibabaCn; // Specify model as a string at runtime let alibaba-cn = AlibabaCn::model_name("deepseek-r1"); ``` ### Using Builder Pattern with Custom Settings ```rust use aisdk::{ core::DynamicModel, providers::AlibabaCn, }; let alibaba-cn = AlibabaCn::::builder() .model_name("deepseek-r1") .api_key("your-api-key") .base_url("https://dashscope.aliyuncs.com/compatible-mode/v1") .path("https://full-url.example/v1/chat/completions") .provider_name("AlibabaCn") .build()?; ``` **Warning**: When using `DynamicModel`, model capabilities are **not validated at compile time**. This means there's no guarantee the model supports requested features (e.g., tool calls, structured output). For compile-time safety, use the typed methods like `AlibabaCn::deepseek_r1()`. ## Next Steps * Take a deeper look at text generation features [Generating Text](/docs/concepts/generating-text#generate_text) / [Streaming Text](/docs/concepts/generating-text#stream_text) * Explore [Structured Output](/docs/concepts/structured-output) for reliable agent data. * Learn how to create [Custom Tools](/docs/concepts/tools). * Learn more about [Agents](/docs/concepts/agents). # Alibaba (/docs/providers/alibaba) AISDK provides first-class support for Alibaba with fully typed model APIs. Model capabilities are enforced at compile time using Rust's type system. This prevents model capability mismatches and guarantees the selected model is valid for the task (e.g. tool calling). ## Installation Enable the Alibaba provider feature: ```bash cargo add aisdk --features alibaba ``` This installs AISDK with the Alibaba provider enabled. Once you have enabled the Alibaba provider, you can use all aisdk features with it. ## Create a Provider Instance To create a provider instance, call `Alibaba::model_name()`, where **model\_name** is the Alibaba model you want to use. Model names are exposed as snake-case methods. ```rust use aisdk::providers::Alibaba; let alibaba = Alibaba::qvq_max(); ``` This initializes the provider with: * Model: `"qvq-max"` * API key from environment (if set with `DASHSCOPE_API_KEY`) * Alibaba's default base URL ([https://dashscope-intl.aliyuncs.com/compatible-mode/v1](https://dashscope-intl.aliyuncs.com/compatible-mode/v1)) ## Basic Text Generation Example using [LanguageModelRequest](https://docs.rs/aisdk/latest/aisdk/core/struct.LanguageModelRequest.html) for text generation. ```rust use aisdk::{ core::LanguageModelRequest, providers::Alibaba, }; #[tokio::main] async fn main() -> Result<(), Box> { let alibaba = Alibaba::qvq_max(); let response = LanguageModelRequest::builder() .model(alibaba) .prompt("Write a short poem about Rust.") .build() .generate_text() .await?; println!("Response text: {:?}", response.text()); Ok(()) } ``` ## Provider Settings You can customize provider configuration using `Alibaba::builder()` ### API Key ```rust let alibaba = Alibaba::::builder() .api_key("your-api-key") .build()?; ``` If not specified, AISDK uses the `DASHSCOPE_API_KEY` environment variable. ### Base URL Useful when routing through a proxy, gateway, or self-hosted compatible endpoint. ```rust let alibaba = Alibaba::::builder() .base_url("https://dashscope-intl.aliyuncs.com/compatible-mode/v1") .build()?; ``` ### Path (Full URL Override) Use `.path(...)` to override the full request URL instead of only the base URL. ```rust let alibaba = Alibaba::::builder() .path("https://full-url.example/v1/chat/completions") .build()?; ``` ### Provider Name For logging, analytics, and observability. ```rust let alibaba = Alibaba::::builder() .provider_name("Alibaba") .build()?; ``` ### Full Custom Configuration Example ```rust let alibaba = Alibaba::::builder() .api_key("your-api-key") .base_url("https://dashscope-intl.aliyuncs.com/compatible-mode/v1") .path("https://full-url.example/v1/chat/completions") .provider_name("Alibaba") .build()?; ``` ## Dynamic Model Selection For runtime model selection (e.g., loading models from config files), use `DynamicModel`: ### Using model\_name() Method with Default Settings ```rust use aisdk::providers::Alibaba; // Specify model as a string at runtime let alibaba = Alibaba::model_name("qvq-max"); ``` ### Using Builder Pattern with Custom Settings ```rust use aisdk::{ core::DynamicModel, providers::Alibaba, }; let alibaba = Alibaba::::builder() .model_name("qvq-max") .api_key("your-api-key") .base_url("https://dashscope-intl.aliyuncs.com/compatible-mode/v1") .path("https://full-url.example/v1/chat/completions") .provider_name("Alibaba") .build()?; ``` **Warning**: When using `DynamicModel`, model capabilities are **not validated at compile time**. This means there's no guarantee the model supports requested features (e.g., tool calls, structured output). For compile-time safety, use the typed methods like `Alibaba::qvq_max()`. ## Next Steps * Take a deeper look at text generation features [Generating Text](/docs/concepts/generating-text#generate_text) / [Streaming Text](/docs/concepts/generating-text#stream_text) * Explore [Structured Output](/docs/concepts/structured-output) for reliable agent data. * Learn how to create [Custom Tools](/docs/concepts/tools). * Learn more about [Agents](/docs/concepts/agents). # AmazonBedrock (/docs/providers/amazon-bedrock) AISDK provides first-class support for AmazonBedrock with fully typed model APIs. Model capabilities are enforced at compile time using Rust's type system. This prevents model capability mismatches and guarantees the selected model is valid for the task (e.g. tool calling). ## Installation Enable the AmazonBedrock provider feature: ```bash cargo add aisdk --features amazon-bedrock ``` This installs AISDK with the AmazonBedrock provider enabled. Once you have enabled the AmazonBedrock provider, you can use all aisdk features with it. ## Create a Provider Instance To create a provider instance, call `AmazonBedrock::model_name()`, where **model\_name** is the AmazonBedrock model you want to use. Model names are exposed as snake-case methods. ```rust use aisdk::providers::AmazonBedrock; let amazon-bedrock = AmazonBedrock::ai21_jamba_1_5_large_v1_0(); ``` This initializes the provider with: * Model: `"ai21.jamba-1-5-large-v1:0"` * API key from environment (if set with `BEDROCK_API_KEY`) * AmazonBedrock's default base URL ([https://bedrock-runtime.us-east-1.amazonaws.com/openai/v1/](https://bedrock-runtime.us-east-1.amazonaws.com/openai/v1/)) ## Basic Text Generation Example using [LanguageModelRequest](https://docs.rs/aisdk/latest/aisdk/core/struct.LanguageModelRequest.html) for text generation. ```rust use aisdk::{ core::LanguageModelRequest, providers::AmazonBedrock, }; #[tokio::main] async fn main() -> Result<(), Box> { let amazon-bedrock = AmazonBedrock::ai21_jamba_1_5_large_v1_0(); let response = LanguageModelRequest::builder() .model(amazon-bedrock) .prompt("Write a short poem about Rust.") .build() .generate_text() .await?; println!("Response text: {:?}", response.text()); Ok(()) } ``` ## Provider Settings You can customize provider configuration using `AmazonBedrock::builder()` ### API Key ```rust let amazon-bedrock = AmazonBedrock::::builder() .api_key("your-api-key") .build()?; ``` If not specified, AISDK uses the `BEDROCK_API_KEY` environment variable. ### Base URL Useful when routing through a proxy, gateway, or self-hosted compatible endpoint. ```rust let amazon-bedrock = AmazonBedrock::::builder() .base_url("https://bedrock-runtime.us-east-1.amazonaws.com/openai/v1/") .build()?; ``` ### Path (Full URL Override) Use `.path(...)` to override the full request URL instead of only the base URL. ```rust let amazon-bedrock = AmazonBedrock::::builder() .path("https://full-url.example/v1/chat/completions") .build()?; ``` ### Provider Name For logging, analytics, and observability. ```rust let amazon-bedrock = AmazonBedrock::::builder() .provider_name("AmazonBedrock") .build()?; ``` ### Full Custom Configuration Example ```rust let amazon-bedrock = AmazonBedrock::::builder() .api_key("your-api-key") .base_url("https://bedrock-runtime.us-east-1.amazonaws.com/openai/v1/") .path("https://full-url.example/v1/chat/completions") .provider_name("AmazonBedrock") .build()?; ``` ## Dynamic Model Selection For runtime model selection (e.g., loading models from config files), use `DynamicModel`: ### Using model\_name() Method with Default Settings ```rust use aisdk::providers::AmazonBedrock; // Specify model as a string at runtime let amazon-bedrock = AmazonBedrock::model_name("ai21.jamba-1-5-large-v1:0"); ``` ### Using Builder Pattern with Custom Settings ```rust use aisdk::{ core::DynamicModel, providers::AmazonBedrock, }; let amazon-bedrock = AmazonBedrock::::builder() .model_name("ai21.jamba-1-5-large-v1:0") .api_key("your-api-key") .base_url("https://bedrock-runtime.us-east-1.amazonaws.com/openai/v1/") .path("https://full-url.example/v1/chat/completions") .provider_name("AmazonBedrock") .build()?; ``` **Warning**: When using `DynamicModel`, model capabilities are **not validated at compile time**. This means there's no guarantee the model supports requested features (e.g., tool calls, structured output). For compile-time safety, use the typed methods like `AmazonBedrock::ai21_jamba_1_5_large_v1_0()`. ## Next Steps * Take a deeper look at text generation features [Generating Text](/docs/concepts/generating-text#generate_text) / [Streaming Text](/docs/concepts/generating-text#stream_text) * Explore [Structured Output](/docs/concepts/structured-output) for reliable agent data. * Learn how to create [Custom Tools](/docs/concepts/tools). * Learn more about [Agents](/docs/concepts/agents). # Anthropic (/docs/providers/anthropic) AISDK provides first-class support for Anthropic with fully typed model APIs. Model capabilities are enforced at compile time using Rust's type system. This prevents model capability mismatches and guarantees the selected model is valid for the task (e.g. tool calling). ## Installation Enable the Anthropic provider feature: ```bash cargo add aisdk --features anthropic ``` This installs AISDK with the Anthropic provider enabled. Once you have enabled the Anthropic provider, you can use all aisdk features with it. ## Create a Provider Instance To create a provider instance, call `Anthropic::model_name()`, where **model\_name** is the Anthropic model you want to use. Model names are exposed as snake-case methods. ```rust use aisdk::providers::Anthropic; let anthropic = Anthropic::claude_3_5_haiku_20241022(); ``` This initializes the provider with: * Model: `"claude-3-5-haiku-20241022"` * API key from environment (if set with `ANTHROPIC_API_KEY`) * Anthropic's default base URL ([https://api.anthropic.com/v1/](https://api.anthropic.com/v1/)) ## Basic Text Generation Example using [LanguageModelRequest](https://docs.rs/aisdk/latest/aisdk/core/struct.LanguageModelRequest.html) for text generation. ```rust use aisdk::{ core::LanguageModelRequest, providers::Anthropic, }; #[tokio::main] async fn main() -> Result<(), Box> { let anthropic = Anthropic::claude_3_5_haiku_20241022(); let response = LanguageModelRequest::builder() .model(anthropic) .prompt("Write a short poem about Rust.") .build() .generate_text() .await?; println!("Response text: {:?}", response.text()); Ok(()) } ``` ## Provider Settings You can customize provider configuration using `Anthropic::builder()` ### API Key ```rust let anthropic = Anthropic::::builder() .api_key("your-api-key") .build()?; ``` If not specified, AISDK uses the `ANTHROPIC_API_KEY` environment variable. ### Base URL Useful when routing through a proxy, gateway, or self-hosted compatible endpoint. ```rust let anthropic = Anthropic::::builder() .base_url("https://api.anthropic.com/v1/") .build()?; ``` ### Path (Full URL Override) Use `.path(...)` to override the full request URL instead of only the base URL. ```rust let anthropic = Anthropic::::builder() .path("https://full-url.example/v1/chat/completions") .build()?; ``` ### Provider Name For logging, analytics, and observability. ```rust let anthropic = Anthropic::::builder() .provider_name("Anthropic") .build()?; ``` ### Full Custom Configuration Example ```rust let anthropic = Anthropic::::builder() .api_key("your-api-key") .base_url("https://api.anthropic.com/v1/") .path("https://full-url.example/v1/chat/completions") .provider_name("Anthropic") .build()?; ``` ## Dynamic Model Selection For runtime model selection (e.g., loading models from config files), use `DynamicModel`: ### Using model\_name() Method with Default Settings ```rust use aisdk::providers::Anthropic; // Specify model as a string at runtime let anthropic = Anthropic::model_name("claude-3-5-haiku-20241022"); ``` ### Using Builder Pattern with Custom Settings ```rust use aisdk::{ core::DynamicModel, providers::Anthropic, }; let anthropic = Anthropic::::builder() .model_name("claude-3-5-haiku-20241022") .api_key("your-api-key") .base_url("https://api.anthropic.com/v1/") .path("https://full-url.example/v1/chat/completions") .provider_name("Anthropic") .build()?; ``` **Warning**: When using `DynamicModel`, model capabilities are **not validated at compile time**. This means there's no guarantee the model supports requested features (e.g., tool calls, structured output). For compile-time safety, use the typed methods like `Anthropic::claude_3_5_haiku_20241022()`. ## Next Steps * Take a deeper look at text generation features [Generating Text](/docs/concepts/generating-text#generate_text) / [Streaming Text](/docs/concepts/generating-text#stream_text) * Explore [Structured Output](/docs/concepts/structured-output) for reliable agent data. * Learn how to create [Custom Tools](/docs/concepts/tools). * Learn more about [Agents](/docs/concepts/agents). # Bailing (/docs/providers/bailing) AISDK provides first-class support for Bailing with fully typed model APIs. Model capabilities are enforced at compile time using Rust's type system. This prevents model capability mismatches and guarantees the selected model is valid for the task (e.g. tool calling). ## Installation Enable the Bailing provider feature: ```bash cargo add aisdk --features bailing ``` This installs AISDK with the Bailing provider enabled. Once you have enabled the Bailing provider, you can use all aisdk features with it. ## Create a Provider Instance To create a provider instance, call `Bailing::model_name()`, where **model\_name** is the Bailing model you want to use. Model names are exposed as snake-case methods. ```rust use aisdk::providers::Bailing; let bailing = Bailing::ling_1t(); ``` This initializes the provider with: * Model: `"Ling-1T"` * API key from environment (if set with `BAILING_API_TOKEN`) * Bailing's default base URL ([https://api.tbox.cn/api/llm/v1/chat/completions](https://api.tbox.cn/api/llm/v1/chat/completions)) ## Basic Text Generation Example using [LanguageModelRequest](https://docs.rs/aisdk/latest/aisdk/core/struct.LanguageModelRequest.html) for text generation. ```rust use aisdk::{ core::LanguageModelRequest, providers::Bailing, }; #[tokio::main] async fn main() -> Result<(), Box> { let bailing = Bailing::ling_1t(); let response = LanguageModelRequest::builder() .model(bailing) .prompt("Write a short poem about Rust.") .build() .generate_text() .await?; println!("Response text: {:?}", response.text()); Ok(()) } ``` ## Provider Settings You can customize provider configuration using `Bailing::builder()` ### API Key ```rust let bailing = Bailing::::builder() .api_key("your-api-key") .build()?; ``` If not specified, AISDK uses the `BAILING_API_TOKEN` environment variable. ### Base URL Useful when routing through a proxy, gateway, or self-hosted compatible endpoint. ```rust let bailing = Bailing::::builder() .base_url("https://api.tbox.cn/api/llm/v1/chat/completions") .build()?; ``` ### Path (Full URL Override) Use `.path(...)` to override the full request URL instead of only the base URL. ```rust let bailing = Bailing::::builder() .path("https://full-url.example/v1/chat/completions") .build()?; ``` ### Provider Name For logging, analytics, and observability. ```rust let bailing = Bailing::::builder() .provider_name("Bailing") .build()?; ``` ### Full Custom Configuration Example ```rust let bailing = Bailing::::builder() .api_key("your-api-key") .base_url("https://api.tbox.cn/api/llm/v1/chat/completions") .path("https://full-url.example/v1/chat/completions") .provider_name("Bailing") .build()?; ``` ## Dynamic Model Selection For runtime model selection (e.g., loading models from config files), use `DynamicModel`: ### Using model\_name() Method with Default Settings ```rust use aisdk::providers::Bailing; // Specify model as a string at runtime let bailing = Bailing::model_name("Ling-1T"); ``` ### Using Builder Pattern with Custom Settings ```rust use aisdk::{ core::DynamicModel, providers::Bailing, }; let bailing = Bailing::::builder() .model_name("Ling-1T") .api_key("your-api-key") .base_url("https://api.tbox.cn/api/llm/v1/chat/completions") .path("https://full-url.example/v1/chat/completions") .provider_name("Bailing") .build()?; ``` **Warning**: When using `DynamicModel`, model capabilities are **not validated at compile time**. This means there's no guarantee the model supports requested features (e.g., tool calls, structured output). For compile-time safety, use the typed methods like `Bailing::ling_1t()`. ## Next Steps * Take a deeper look at text generation features [Generating Text](/docs/concepts/generating-text#generate_text) / [Streaming Text](/docs/concepts/generating-text#stream_text) * Explore [Structured Output](/docs/concepts/structured-output) for reliable agent data. * Learn how to create [Custom Tools](/docs/concepts/tools). * Learn more about [Agents](/docs/concepts/agents). # Baseten (/docs/providers/baseten) AISDK provides first-class support for Baseten with fully typed model APIs. Model capabilities are enforced at compile time using Rust's type system. This prevents model capability mismatches and guarantees the selected model is valid for the task (e.g. tool calling). ## Installation Enable the Baseten provider feature: ```bash cargo add aisdk --features baseten ``` This installs AISDK with the Baseten provider enabled. Once you have enabled the Baseten provider, you can use all aisdk features with it. ## Create a Provider Instance To create a provider instance, call `Baseten::model_name()`, where **model\_name** is the Baseten model you want to use. Model names are exposed as snake-case methods. ```rust use aisdk::providers::Baseten; let baseten = Baseten::qwen_qwen3_coder_480b_a35b_instruct(); ``` This initializes the provider with: * Model: `"Qwen/Qwen3-Coder-480B-A35B-Instruct"` * API key from environment (if set with `BASETEN_API_KEY`) * Baseten's default base URL ([https://inference.baseten.co/v1](https://inference.baseten.co/v1)) ## Basic Text Generation Example using [LanguageModelRequest](https://docs.rs/aisdk/latest/aisdk/core/struct.LanguageModelRequest.html) for text generation. ```rust use aisdk::{ core::LanguageModelRequest, providers::Baseten, }; #[tokio::main] async fn main() -> Result<(), Box> { let baseten = Baseten::qwen_qwen3_coder_480b_a35b_instruct(); let response = LanguageModelRequest::builder() .model(baseten) .prompt("Write a short poem about Rust.") .build() .generate_text() .await?; println!("Response text: {:?}", response.text()); Ok(()) } ``` ## Provider Settings You can customize provider configuration using `Baseten::builder()` ### API Key ```rust let baseten = Baseten::::builder() .api_key("your-api-key") .build()?; ``` If not specified, AISDK uses the `BASETEN_API_KEY` environment variable. ### Base URL Useful when routing through a proxy, gateway, or self-hosted compatible endpoint. ```rust let baseten = Baseten::::builder() .base_url("https://inference.baseten.co/v1") .build()?; ``` ### Path (Full URL Override) Use `.path(...)` to override the full request URL instead of only the base URL. ```rust let baseten = Baseten::::builder() .path("https://full-url.example/v1/chat/completions") .build()?; ``` ### Provider Name For logging, analytics, and observability. ```rust let baseten = Baseten::::builder() .provider_name("Baseten") .build()?; ``` ### Full Custom Configuration Example ```rust let baseten = Baseten::::builder() .api_key("your-api-key") .base_url("https://inference.baseten.co/v1") .path("https://full-url.example/v1/chat/completions") .provider_name("Baseten") .build()?; ``` ## Dynamic Model Selection For runtime model selection (e.g., loading models from config files), use `DynamicModel`: ### Using model\_name() Method with Default Settings ```rust use aisdk::providers::Baseten; // Specify model as a string at runtime let baseten = Baseten::model_name("Qwen/Qwen3-Coder-480B-A35B-Instruct"); ``` ### Using Builder Pattern with Custom Settings ```rust use aisdk::{ core::DynamicModel, providers::Baseten, }; let baseten = Baseten::::builder() .model_name("Qwen/Qwen3-Coder-480B-A35B-Instruct") .api_key("your-api-key") .base_url("https://inference.baseten.co/v1") .path("https://full-url.example/v1/chat/completions") .provider_name("Baseten") .build()?; ``` **Warning**: When using `DynamicModel`, model capabilities are **not validated at compile time**. This means there's no guarantee the model supports requested features (e.g., tool calls, structured output). For compile-time safety, use the typed methods like `Baseten::qwen_qwen3_coder_480b_a35b_instruct()`. ## Next Steps * Take a deeper look at text generation features [Generating Text](/docs/concepts/generating-text#generate_text) / [Streaming Text](/docs/concepts/generating-text#stream_text) * Explore [Structured Output](/docs/concepts/structured-output) for reliable agent data. * Learn how to create [Custom Tools](/docs/concepts/tools). * Learn more about [Agents](/docs/concepts/agents). # Berget (/docs/providers/berget) AISDK provides first-class support for Berget with fully typed model APIs. Model capabilities are enforced at compile time using Rust's type system. This prevents model capability mismatches and guarantees the selected model is valid for the task (e.g. tool calling). ## Installation Enable the Berget provider feature: ```bash cargo add aisdk --features berget ``` This installs AISDK with the Berget provider enabled. Once you have enabled the Berget provider, you can use all aisdk features with it. ## Create a Provider Instance To create a provider instance, call `Berget::model_name()`, where **model\_name** is the Berget model you want to use. Model names are exposed as snake-case methods. ```rust use aisdk::providers::Berget; let berget = Berget::baai_bge_reranker_v2_m3(); ``` This initializes the provider with: * Model: `"BAAI/bge-reranker-v2-m3"` * API key from environment (if set with `BERGET_API_KEY`) * Berget's default base URL ([https://api.berget.ai/v1](https://api.berget.ai/v1)) ## Basic Text Generation Example using [LanguageModelRequest](https://docs.rs/aisdk/latest/aisdk/core/struct.LanguageModelRequest.html) for text generation. ```rust use aisdk::{ core::LanguageModelRequest, providers::Berget, }; #[tokio::main] async fn main() -> Result<(), Box> { let berget = Berget::baai_bge_reranker_v2_m3(); let response = LanguageModelRequest::builder() .model(berget) .prompt("Write a short poem about Rust.") .build() .generate_text() .await?; println!("Response text: {:?}", response.text()); Ok(()) } ``` ## Provider Settings You can customize provider configuration using `Berget::builder()` ### API Key ```rust let berget = Berget::::builder() .api_key("your-api-key") .build()?; ``` If not specified, AISDK uses the `BERGET_API_KEY` environment variable. ### Base URL Useful when routing through a proxy, gateway, or self-hosted compatible endpoint. ```rust let berget = Berget::::builder() .base_url("https://api.berget.ai/v1") .build()?; ``` ### Path (Full URL Override) Use `.path(...)` to override the full request URL instead of only the base URL. ```rust let berget = Berget::::builder() .path("https://full-url.example/v1/chat/completions") .build()?; ``` ### Provider Name For logging, analytics, and observability. ```rust let berget = Berget::::builder() .provider_name("Berget") .build()?; ``` ### Full Custom Configuration Example ```rust let berget = Berget::::builder() .api_key("your-api-key") .base_url("https://api.berget.ai/v1") .path("https://full-url.example/v1/chat/completions") .provider_name("Berget") .build()?; ``` ## Dynamic Model Selection For runtime model selection (e.g., loading models from config files), use `DynamicModel`: ### Using model\_name() Method with Default Settings ```rust use aisdk::providers::Berget; // Specify model as a string at runtime let berget = Berget::model_name("BAAI/bge-reranker-v2-m3"); ``` ### Using Builder Pattern with Custom Settings ```rust use aisdk::{ core::DynamicModel, providers::Berget, }; let berget = Berget::::builder() .model_name("BAAI/bge-reranker-v2-m3") .api_key("your-api-key") .base_url("https://api.berget.ai/v1") .path("https://full-url.example/v1/chat/completions") .provider_name("Berget") .build()?; ``` **Warning**: When using `DynamicModel`, model capabilities are **not validated at compile time**. This means there's no guarantee the model supports requested features (e.g., tool calls, structured output). For compile-time safety, use the typed methods like `Berget::baai_bge_reranker_v2_m3()`. ## Next Steps * Take a deeper look at text generation features [Generating Text](/docs/concepts/generating-text#generate_text) / [Streaming Text](/docs/concepts/generating-text#stream_text) * Explore [Structured Output](/docs/concepts/structured-output) for reliable agent data. * Learn how to create [Custom Tools](/docs/concepts/tools). * Learn more about [Agents](/docs/concepts/agents). # Chutes (/docs/providers/chutes) AISDK provides first-class support for Chutes with fully typed model APIs. Model capabilities are enforced at compile time using Rust's type system. This prevents model capability mismatches and guarantees the selected model is valid for the task (e.g. tool calling). ## Installation Enable the Chutes provider feature: ```bash cargo add aisdk --features chutes ``` This installs AISDK with the Chutes provider enabled. Once you have enabled the Chutes provider, you can use all aisdk features with it. ## Create a Provider Instance To create a provider instance, call `Chutes::model_name()`, where **model\_name** is the Chutes model you want to use. Model names are exposed as snake-case methods. ```rust use aisdk::providers::Chutes; let chutes = Chutes::minimaxai_minimax_m2_1_tee(); ``` This initializes the provider with: * Model: `"MiniMaxAI/MiniMax-M2.1-TEE"` * API key from environment (if set with `CHUTES_API_KEY`) * Chutes's default base URL ([https://llm.chutes.ai/v1](https://llm.chutes.ai/v1)) ## Basic Text Generation Example using [LanguageModelRequest](https://docs.rs/aisdk/latest/aisdk/core/struct.LanguageModelRequest.html) for text generation. ```rust use aisdk::{ core::LanguageModelRequest, providers::Chutes, }; #[tokio::main] async fn main() -> Result<(), Box> { let chutes = Chutes::minimaxai_minimax_m2_1_tee(); let response = LanguageModelRequest::builder() .model(chutes) .prompt("Write a short poem about Rust.") .build() .generate_text() .await?; println!("Response text: {:?}", response.text()); Ok(()) } ``` ## Provider Settings You can customize provider configuration using `Chutes::builder()` ### API Key ```rust let chutes = Chutes::::builder() .api_key("your-api-key") .build()?; ``` If not specified, AISDK uses the `CHUTES_API_KEY` environment variable. ### Base URL Useful when routing through a proxy, gateway, or self-hosted compatible endpoint. ```rust let chutes = Chutes::::builder() .base_url("https://llm.chutes.ai/v1") .build()?; ``` ### Path (Full URL Override) Use `.path(...)` to override the full request URL instead of only the base URL. ```rust let chutes = Chutes::::builder() .path("https://full-url.example/v1/chat/completions") .build()?; ``` ### Provider Name For logging, analytics, and observability. ```rust let chutes = Chutes::::builder() .provider_name("Chutes") .build()?; ``` ### Full Custom Configuration Example ```rust let chutes = Chutes::::builder() .api_key("your-api-key") .base_url("https://llm.chutes.ai/v1") .path("https://full-url.example/v1/chat/completions") .provider_name("Chutes") .build()?; ``` ## Dynamic Model Selection For runtime model selection (e.g., loading models from config files), use `DynamicModel`: ### Using model\_name() Method with Default Settings ```rust use aisdk::providers::Chutes; // Specify model as a string at runtime let chutes = Chutes::model_name("MiniMaxAI/MiniMax-M2.1-TEE"); ``` ### Using Builder Pattern with Custom Settings ```rust use aisdk::{ core::DynamicModel, providers::Chutes, }; let chutes = Chutes::::builder() .model_name("MiniMaxAI/MiniMax-M2.1-TEE") .api_key("your-api-key") .base_url("https://llm.chutes.ai/v1") .path("https://full-url.example/v1/chat/completions") .provider_name("Chutes") .build()?; ``` **Warning**: When using `DynamicModel`, model capabilities are **not validated at compile time**. This means there's no guarantee the model supports requested features (e.g., tool calls, structured output). For compile-time safety, use the typed methods like `Chutes::minimaxai_minimax_m2_1_tee()`. ## Next Steps * Take a deeper look at text generation features [Generating Text](/docs/concepts/generating-text#generate_text) / [Streaming Text](/docs/concepts/generating-text#stream_text) * Explore [Structured Output](/docs/concepts/structured-output) for reliable agent data. * Learn how to create [Custom Tools](/docs/concepts/tools). * Learn more about [Agents](/docs/concepts/agents). # CloudflareAiGateway (/docs/providers/cloudflare-ai-gateway) AISDK provides first-class support for CloudflareAiGateway with fully typed model APIs. Model capabilities are enforced at compile time using Rust's type system. This prevents model capability mismatches and guarantees the selected model is valid for the task (e.g. tool calling). ## Installation Enable the CloudflareAiGateway provider feature: ```bash cargo add aisdk --features cloudflare-ai-gateway ``` This installs AISDK with the CloudflareAiGateway provider enabled. Once you have enabled the CloudflareAiGateway provider, you can use all aisdk features with it. ## Create a Provider Instance To create a provider instance, call `CloudflareAiGateway::model_name()`, where **model\_name** is the CloudflareAiGateway model you want to use. Model names are exposed as snake-case methods. ```rust use aisdk::providers::CloudflareAiGateway; let cloudflare-ai-gateway = CloudflareAiGateway::anthropic_claude_3_5_haiku(); ``` This initializes the provider with: * Model: `"anthropic/claude-3-5-haiku"` * API key from environment (if set with `CLOUDFLARE_API_TOKEN`) * CloudflareAiGateway's default base URL ([https://gateway.ai.cloudflare.com/v1/$\{CLOUDFLARE\_ACCOUNT\_ID}/$\{CLOUDFLARE\_GATEWAY\_ID}/compat/](https://gateway.ai.cloudflare.com/v1/$\{CLOUDFLARE_ACCOUNT_ID}/$\{CLOUDFLARE_GATEWAY_ID}/compat/)) ## Basic Text Generation Example using [LanguageModelRequest](https://docs.rs/aisdk/latest/aisdk/core/struct.LanguageModelRequest.html) for text generation. ```rust use aisdk::{ core::LanguageModelRequest, providers::CloudflareAiGateway, }; #[tokio::main] async fn main() -> Result<(), Box> { let cloudflare-ai-gateway = CloudflareAiGateway::anthropic_claude_3_5_haiku(); let response = LanguageModelRequest::builder() .model(cloudflare-ai-gateway) .prompt("Write a short poem about Rust.") .build() .generate_text() .await?; println!("Response text: {:?}", response.text()); Ok(()) } ``` ## Provider Settings You can customize provider configuration using `CloudflareAiGateway::builder()` ### API Key ```rust let cloudflare-ai-gateway = CloudflareAiGateway::::builder() .api_key("your-api-key") .build()?; ``` If not specified, AISDK uses the `CLOUDFLARE_API_TOKEN` environment variable. ### Base URL Useful when routing through a proxy, gateway, or self-hosted compatible endpoint. ```rust let cloudflare-ai-gateway = CloudflareAiGateway::::builder() .base_url("https://gateway.ai.cloudflare.com/v1/${CLOUDFLARE_ACCOUNT_ID}/${CLOUDFLARE_GATEWAY_ID}/compat/") .build()?; ``` ### Path (Full URL Override) Use `.path(...)` to override the full request URL instead of only the base URL. ```rust let cloudflare-ai-gateway = CloudflareAiGateway::::builder() .path("https://full-url.example/v1/chat/completions") .build()?; ``` ### Provider Name For logging, analytics, and observability. ```rust let cloudflare-ai-gateway = CloudflareAiGateway::::builder() .provider_name("CloudflareAiGateway") .build()?; ``` ### Full Custom Configuration Example ```rust let cloudflare-ai-gateway = CloudflareAiGateway::::builder() .api_key("your-api-key") .base_url("https://gateway.ai.cloudflare.com/v1/${CLOUDFLARE_ACCOUNT_ID}/${CLOUDFLARE_GATEWAY_ID}/compat/") .path("https://full-url.example/v1/chat/completions") .provider_name("CloudflareAiGateway") .build()?; ``` ## Dynamic Model Selection For runtime model selection (e.g., loading models from config files), use `DynamicModel`: ### Using model\_name() Method with Default Settings ```rust use aisdk::providers::CloudflareAiGateway; // Specify model as a string at runtime let cloudflare-ai-gateway = CloudflareAiGateway::model_name("anthropic/claude-3-5-haiku"); ``` ### Using Builder Pattern with Custom Settings ```rust use aisdk::{ core::DynamicModel, providers::CloudflareAiGateway, }; let cloudflare-ai-gateway = CloudflareAiGateway::::builder() .model_name("anthropic/claude-3-5-haiku") .api_key("your-api-key") .base_url("https://gateway.ai.cloudflare.com/v1/${CLOUDFLARE_ACCOUNT_ID}/${CLOUDFLARE_GATEWAY_ID}/compat/") .path("https://full-url.example/v1/chat/completions") .provider_name("CloudflareAiGateway") .build()?; ``` **Warning**: When using `DynamicModel`, model capabilities are **not validated at compile time**. This means there's no guarantee the model supports requested features (e.g., tool calls, structured output). For compile-time safety, use the typed methods like `CloudflareAiGateway::anthropic_claude_3_5_haiku()`. ## Next Steps * Take a deeper look at text generation features [Generating Text](/docs/concepts/generating-text#generate_text) / [Streaming Text](/docs/concepts/generating-text#stream_text) * Explore [Structured Output](/docs/concepts/structured-output) for reliable agent data. * Learn how to create [Custom Tools](/docs/concepts/tools). * Learn more about [Agents](/docs/concepts/agents). # CloudflareWorkersAi (/docs/providers/cloudflare-workers-ai) AISDK provides first-class support for CloudflareWorkersAi with fully typed model APIs. Model capabilities are enforced at compile time using Rust's type system. This prevents model capability mismatches and guarantees the selected model is valid for the task (e.g. tool calling). ## Installation Enable the CloudflareWorkersAi provider feature: ```bash cargo add aisdk --features cloudflare-workers-ai ``` This installs AISDK with the CloudflareWorkersAi provider enabled. Once you have enabled the CloudflareWorkersAi provider, you can use all aisdk features with it. ## Create a Provider Instance To create a provider instance, call `CloudflareWorkersAi::model_name()`, where **model\_name** is the CloudflareWorkersAi model you want to use. Model names are exposed as snake-case methods. ```rust use aisdk::providers::CloudflareWorkersAi; let cloudflare-workers-ai = CloudflareWorkersAi::ai4bharat_indictrans2_en_indic_1b(); ``` This initializes the provider with: * Model: `"@cf/ai4bharat/indictrans2-en-indic-1B"` * API key from environment (if set with `CLOUDFLARE_ACCOUNT_ID`) * CloudflareWorkersAi's default base URL ([https://api.cloudflare.com/client/v4/accounts/$\{CLOUDFLARE\_ACCOUNT\_ID}/ai/v1](https://api.cloudflare.com/client/v4/accounts/$\{CLOUDFLARE_ACCOUNT_ID}/ai/v1)) ## Basic Text Generation Example using [LanguageModelRequest](https://docs.rs/aisdk/latest/aisdk/core/struct.LanguageModelRequest.html) for text generation. ```rust use aisdk::{ core::LanguageModelRequest, providers::CloudflareWorkersAi, }; #[tokio::main] async fn main() -> Result<(), Box> { let cloudflare-workers-ai = CloudflareWorkersAi::ai4bharat_indictrans2_en_indic_1b(); let response = LanguageModelRequest::builder() .model(cloudflare-workers-ai) .prompt("Write a short poem about Rust.") .build() .generate_text() .await?; println!("Response text: {:?}", response.text()); Ok(()) } ``` ## Provider Settings You can customize provider configuration using `CloudflareWorkersAi::builder()` ### API Key ```rust let cloudflare-workers-ai = CloudflareWorkersAi::::builder() .api_key("your-api-key") .build()?; ``` If not specified, AISDK uses the `CLOUDFLARE_ACCOUNT_ID` environment variable. ### Base URL Useful when routing through a proxy, gateway, or self-hosted compatible endpoint. ```rust let cloudflare-workers-ai = CloudflareWorkersAi::::builder() .base_url("https://api.cloudflare.com/client/v4/accounts/${CLOUDFLARE_ACCOUNT_ID}/ai/v1") .build()?; ``` ### Path (Full URL Override) Use `.path(...)` to override the full request URL instead of only the base URL. ```rust let cloudflare-workers-ai = CloudflareWorkersAi::::builder() .path("https://full-url.example/v1/chat/completions") .build()?; ``` ### Provider Name For logging, analytics, and observability. ```rust let cloudflare-workers-ai = CloudflareWorkersAi::::builder() .provider_name("CloudflareWorkersAi") .build()?; ``` ### Full Custom Configuration Example ```rust let cloudflare-workers-ai = CloudflareWorkersAi::::builder() .api_key("your-api-key") .base_url("https://api.cloudflare.com/client/v4/accounts/${CLOUDFLARE_ACCOUNT_ID}/ai/v1") .path("https://full-url.example/v1/chat/completions") .provider_name("CloudflareWorkersAi") .build()?; ``` ## Dynamic Model Selection For runtime model selection (e.g., loading models from config files), use `DynamicModel`: ### Using model\_name() Method with Default Settings ```rust use aisdk::providers::CloudflareWorkersAi; // Specify model as a string at runtime let cloudflare-workers-ai = CloudflareWorkersAi::model_name("@cf/ai4bharat/indictrans2-en-indic-1B"); ``` ### Using Builder Pattern with Custom Settings ```rust use aisdk::{ core::DynamicModel, providers::CloudflareWorkersAi, }; let cloudflare-workers-ai = CloudflareWorkersAi::::builder() .model_name("@cf/ai4bharat/indictrans2-en-indic-1B") .api_key("your-api-key") .base_url("https://api.cloudflare.com/client/v4/accounts/${CLOUDFLARE_ACCOUNT_ID}/ai/v1") .path("https://full-url.example/v1/chat/completions") .provider_name("CloudflareWorkersAi") .build()?; ``` **Warning**: When using `DynamicModel`, model capabilities are **not validated at compile time**. This means there's no guarantee the model supports requested features (e.g., tool calls, structured output). For compile-time safety, use the typed methods like `CloudflareWorkersAi::ai4bharat_indictrans2_en_indic_1b()`. ## Next Steps * Take a deeper look at text generation features [Generating Text](/docs/concepts/generating-text#generate_text) / [Streaming Text](/docs/concepts/generating-text#stream_text) * Explore [Structured Output](/docs/concepts/structured-output) for reliable agent data. * Learn how to create [Custom Tools](/docs/concepts/tools). * Learn more about [Agents](/docs/concepts/agents). # Cortecs (/docs/providers/cortecs) AISDK provides first-class support for Cortecs with fully typed model APIs. Model capabilities are enforced at compile time using Rust's type system. This prevents model capability mismatches and guarantees the selected model is valid for the task (e.g. tool calling). ## Installation Enable the Cortecs provider feature: ```bash cargo add aisdk --features cortecs ``` This installs AISDK with the Cortecs provider enabled. Once you have enabled the Cortecs provider, you can use all aisdk features with it. ## Create a Provider Instance To create a provider instance, call `Cortecs::model_name()`, where **model\_name** is the Cortecs model you want to use. Model names are exposed as snake-case methods. ```rust use aisdk::providers::Cortecs; let cortecs = Cortecs::claude_4_5_sonnet(); ``` This initializes the provider with: * Model: `"claude-4-5-sonnet"` * API key from environment (if set with `CORTECS_API_KEY`) * Cortecs's default base URL ([https://api.cortecs.ai/v1](https://api.cortecs.ai/v1)) ## Basic Text Generation Example using [LanguageModelRequest](https://docs.rs/aisdk/latest/aisdk/core/struct.LanguageModelRequest.html) for text generation. ```rust use aisdk::{ core::LanguageModelRequest, providers::Cortecs, }; #[tokio::main] async fn main() -> Result<(), Box> { let cortecs = Cortecs::claude_4_5_sonnet(); let response = LanguageModelRequest::builder() .model(cortecs) .prompt("Write a short poem about Rust.") .build() .generate_text() .await?; println!("Response text: {:?}", response.text()); Ok(()) } ``` ## Provider Settings You can customize provider configuration using `Cortecs::builder()` ### API Key ```rust let cortecs = Cortecs::::builder() .api_key("your-api-key") .build()?; ``` If not specified, AISDK uses the `CORTECS_API_KEY` environment variable. ### Base URL Useful when routing through a proxy, gateway, or self-hosted compatible endpoint. ```rust let cortecs = Cortecs::::builder() .base_url("https://api.cortecs.ai/v1") .build()?; ``` ### Path (Full URL Override) Use `.path(...)` to override the full request URL instead of only the base URL. ```rust let cortecs = Cortecs::::builder() .path("https://full-url.example/v1/chat/completions") .build()?; ``` ### Provider Name For logging, analytics, and observability. ```rust let cortecs = Cortecs::::builder() .provider_name("Cortecs") .build()?; ``` ### Full Custom Configuration Example ```rust let cortecs = Cortecs::::builder() .api_key("your-api-key") .base_url("https://api.cortecs.ai/v1") .path("https://full-url.example/v1/chat/completions") .provider_name("Cortecs") .build()?; ``` ## Dynamic Model Selection For runtime model selection (e.g., loading models from config files), use `DynamicModel`: ### Using model\_name() Method with Default Settings ```rust use aisdk::providers::Cortecs; // Specify model as a string at runtime let cortecs = Cortecs::model_name("claude-4-5-sonnet"); ``` ### Using Builder Pattern with Custom Settings ```rust use aisdk::{ core::DynamicModel, providers::Cortecs, }; let cortecs = Cortecs::::builder() .model_name("claude-4-5-sonnet") .api_key("your-api-key") .base_url("https://api.cortecs.ai/v1") .path("https://full-url.example/v1/chat/completions") .provider_name("Cortecs") .build()?; ``` **Warning**: When using `DynamicModel`, model capabilities are **not validated at compile time**. This means there's no guarantee the model supports requested features (e.g., tool calls, structured output). For compile-time safety, use the typed methods like `Cortecs::claude_4_5_sonnet()`. ## Next Steps * Take a deeper look at text generation features [Generating Text](/docs/concepts/generating-text#generate_text) / [Streaming Text](/docs/concepts/generating-text#stream_text) * Explore [Structured Output](/docs/concepts/structured-output) for reliable agent data. * Learn how to create [Custom Tools](/docs/concepts/tools). * Learn more about [Agents](/docs/concepts/agents). # Deepseek (/docs/providers/deepseek) AISDK provides first-class support for Deepseek with fully typed model APIs. Model capabilities are enforced at compile time using Rust's type system. This prevents model capability mismatches and guarantees the selected model is valid for the task (e.g. tool calling). ## Installation Enable the Deepseek provider feature: ```bash cargo add aisdk --features deepseek ``` This installs AISDK with the Deepseek provider enabled. Once you have enabled the Deepseek provider, you can use all aisdk features with it. ## Create a Provider Instance To create a provider instance, call `Deepseek::model_name()`, where **model\_name** is the Deepseek model you want to use. Model names are exposed as snake-case methods. ```rust use aisdk::providers::Deepseek; let deepseek = Deepseek::deepseek_chat(); ``` This initializes the provider with: * Model: `"deepseek-chat"` * API key from environment (if set with `DEEPSEEK_API_KEY`) * Deepseek's default base URL ([https://api.deepseek.com](https://api.deepseek.com)) ## Basic Text Generation Example using [LanguageModelRequest](https://docs.rs/aisdk/latest/aisdk/core/struct.LanguageModelRequest.html) for text generation. ```rust use aisdk::{ core::LanguageModelRequest, providers::Deepseek, }; #[tokio::main] async fn main() -> Result<(), Box> { let deepseek = Deepseek::deepseek_chat(); let response = LanguageModelRequest::builder() .model(deepseek) .prompt("Write a short poem about Rust.") .build() .generate_text() .await?; println!("Response text: {:?}", response.text()); Ok(()) } ``` ## Provider Settings You can customize provider configuration using `Deepseek::builder()` ### API Key ```rust let deepseek = Deepseek::::builder() .api_key("your-api-key") .build()?; ``` If not specified, AISDK uses the `DEEPSEEK_API_KEY` environment variable. ### Base URL Useful when routing through a proxy, gateway, or self-hosted compatible endpoint. ```rust let deepseek = Deepseek::::builder() .base_url("https://api.deepseek.com") .build()?; ``` ### Path (Full URL Override) Use `.path(...)` to override the full request URL instead of only the base URL. ```rust let deepseek = Deepseek::::builder() .path("https://full-url.example/v1/chat/completions") .build()?; ``` ### Provider Name For logging, analytics, and observability. ```rust let deepseek = Deepseek::::builder() .provider_name("Deepseek") .build()?; ``` ### Full Custom Configuration Example ```rust let deepseek = Deepseek::::builder() .api_key("your-api-key") .base_url("https://api.deepseek.com") .path("https://full-url.example/v1/chat/completions") .provider_name("Deepseek") .build()?; ``` ## Dynamic Model Selection For runtime model selection (e.g., loading models from config files), use `DynamicModel`: ### Using model\_name() Method with Default Settings ```rust use aisdk::providers::Deepseek; // Specify model as a string at runtime let deepseek = Deepseek::model_name("deepseek-chat"); ``` ### Using Builder Pattern with Custom Settings ```rust use aisdk::{ core::DynamicModel, providers::Deepseek, }; let deepseek = Deepseek::::builder() .model_name("deepseek-chat") .api_key("your-api-key") .base_url("https://api.deepseek.com") .path("https://full-url.example/v1/chat/completions") .provider_name("Deepseek") .build()?; ``` **Warning**: When using `DynamicModel`, model capabilities are **not validated at compile time**. This means there's no guarantee the model supports requested features (e.g., tool calls, structured output). For compile-time safety, use the typed methods like `Deepseek::deepseek_chat()`. ## Next Steps * Take a deeper look at text generation features [Generating Text](/docs/concepts/generating-text#generate_text) / [Streaming Text](/docs/concepts/generating-text#stream_text) * Explore [Structured Output](/docs/concepts/structured-output) for reliable agent data. * Learn how to create [Custom Tools](/docs/concepts/tools). * Learn more about [Agents](/docs/concepts/agents). # Fastrouter (/docs/providers/fastrouter) AISDK provides first-class support for Fastrouter with fully typed model APIs. Model capabilities are enforced at compile time using Rust's type system. This prevents model capability mismatches and guarantees the selected model is valid for the task (e.g. tool calling). ## Installation Enable the Fastrouter provider feature: ```bash cargo add aisdk --features fastrouter ``` This installs AISDK with the Fastrouter provider enabled. Once you have enabled the Fastrouter provider, you can use all aisdk features with it. ## Create a Provider Instance To create a provider instance, call `Fastrouter::model_name()`, where **model\_name** is the Fastrouter model you want to use. Model names are exposed as snake-case methods. ```rust use aisdk::providers::Fastrouter; let fastrouter = Fastrouter::anthropic_claude_opus_4_1(); ``` This initializes the provider with: * Model: `"anthropic/claude-opus-4.1"` * API key from environment (if set with `FASTROUTER_API_KEY`) * Fastrouter's default base URL ([https://go.fastrouter.ai/api/v1](https://go.fastrouter.ai/api/v1)) ## Basic Text Generation Example using [LanguageModelRequest](https://docs.rs/aisdk/latest/aisdk/core/struct.LanguageModelRequest.html) for text generation. ```rust use aisdk::{ core::LanguageModelRequest, providers::Fastrouter, }; #[tokio::main] async fn main() -> Result<(), Box> { let fastrouter = Fastrouter::anthropic_claude_opus_4_1(); let response = LanguageModelRequest::builder() .model(fastrouter) .prompt("Write a short poem about Rust.") .build() .generate_text() .await?; println!("Response text: {:?}", response.text()); Ok(()) } ``` ## Provider Settings You can customize provider configuration using `Fastrouter::builder()` ### API Key ```rust let fastrouter = Fastrouter::::builder() .api_key("your-api-key") .build()?; ``` If not specified, AISDK uses the `FASTROUTER_API_KEY` environment variable. ### Base URL Useful when routing through a proxy, gateway, or self-hosted compatible endpoint. ```rust let fastrouter = Fastrouter::::builder() .base_url("https://go.fastrouter.ai/api/v1") .build()?; ``` ### Path (Full URL Override) Use `.path(...)` to override the full request URL instead of only the base URL. ```rust let fastrouter = Fastrouter::::builder() .path("https://full-url.example/v1/chat/completions") .build()?; ``` ### Provider Name For logging, analytics, and observability. ```rust let fastrouter = Fastrouter::::builder() .provider_name("Fastrouter") .build()?; ``` ### Full Custom Configuration Example ```rust let fastrouter = Fastrouter::::builder() .api_key("your-api-key") .base_url("https://go.fastrouter.ai/api/v1") .path("https://full-url.example/v1/chat/completions") .provider_name("Fastrouter") .build()?; ``` ## Dynamic Model Selection For runtime model selection (e.g., loading models from config files), use `DynamicModel`: ### Using model\_name() Method with Default Settings ```rust use aisdk::providers::Fastrouter; // Specify model as a string at runtime let fastrouter = Fastrouter::model_name("anthropic/claude-opus-4.1"); ``` ### Using Builder Pattern with Custom Settings ```rust use aisdk::{ core::DynamicModel, providers::Fastrouter, }; let fastrouter = Fastrouter::::builder() .model_name("anthropic/claude-opus-4.1") .api_key("your-api-key") .base_url("https://go.fastrouter.ai/api/v1") .path("https://full-url.example/v1/chat/completions") .provider_name("Fastrouter") .build()?; ``` **Warning**: When using `DynamicModel`, model capabilities are **not validated at compile time**. This means there's no guarantee the model supports requested features (e.g., tool calls, structured output). For compile-time safety, use the typed methods like `Fastrouter::anthropic_claude_opus_4_1()`. ## Next Steps * Take a deeper look at text generation features [Generating Text](/docs/concepts/generating-text#generate_text) / [Streaming Text](/docs/concepts/generating-text#stream_text) * Explore [Structured Output](/docs/concepts/structured-output) for reliable agent data. * Learn how to create [Custom Tools](/docs/concepts/tools). * Learn more about [Agents](/docs/concepts/agents). # FireworksAi (/docs/providers/fireworks-ai) AISDK provides first-class support for FireworksAi with fully typed model APIs. Model capabilities are enforced at compile time using Rust's type system. This prevents model capability mismatches and guarantees the selected model is valid for the task (e.g. tool calling). ## Installation Enable the FireworksAi provider feature: ```bash cargo add aisdk --features fireworks-ai ``` This installs AISDK with the FireworksAi provider enabled. Once you have enabled the FireworksAi provider, you can use all aisdk features with it. ## Create a Provider Instance To create a provider instance, call `FireworksAi::model_name()`, where **model\_name** is the FireworksAi model you want to use. Model names are exposed as snake-case methods. ```rust use aisdk::providers::FireworksAi; let fireworks-ai = FireworksAi::models_deepseek_r1_0528(); ``` This initializes the provider with: * Model: `"accounts/fireworks/models/deepseek-r1-0528"` * API key from environment (if set with `FIREWORKS_API_KEY`) * FireworksAi's default base URL ([https://api.fireworks.ai/inference/v1/](https://api.fireworks.ai/inference/v1/)) ## Basic Text Generation Example using [LanguageModelRequest](https://docs.rs/aisdk/latest/aisdk/core/struct.LanguageModelRequest.html) for text generation. ```rust use aisdk::{ core::LanguageModelRequest, providers::FireworksAi, }; #[tokio::main] async fn main() -> Result<(), Box> { let fireworks-ai = FireworksAi::models_deepseek_r1_0528(); let response = LanguageModelRequest::builder() .model(fireworks-ai) .prompt("Write a short poem about Rust.") .build() .generate_text() .await?; println!("Response text: {:?}", response.text()); Ok(()) } ``` ## Provider Settings You can customize provider configuration using `FireworksAi::builder()` ### API Key ```rust let fireworks-ai = FireworksAi::::builder() .api_key("your-api-key") .build()?; ``` If not specified, AISDK uses the `FIREWORKS_API_KEY` environment variable. ### Base URL Useful when routing through a proxy, gateway, or self-hosted compatible endpoint. ```rust let fireworks-ai = FireworksAi::::builder() .base_url("https://api.fireworks.ai/inference/v1/") .build()?; ``` ### Path (Full URL Override) Use `.path(...)` to override the full request URL instead of only the base URL. ```rust let fireworks-ai = FireworksAi::::builder() .path("https://full-url.example/v1/chat/completions") .build()?; ``` ### Provider Name For logging, analytics, and observability. ```rust let fireworks-ai = FireworksAi::::builder() .provider_name("FireworksAi") .build()?; ``` ### Full Custom Configuration Example ```rust let fireworks-ai = FireworksAi::::builder() .api_key("your-api-key") .base_url("https://api.fireworks.ai/inference/v1/") .path("https://full-url.example/v1/chat/completions") .provider_name("FireworksAi") .build()?; ``` ## Dynamic Model Selection For runtime model selection (e.g., loading models from config files), use `DynamicModel`: ### Using model\_name() Method with Default Settings ```rust use aisdk::providers::FireworksAi; // Specify model as a string at runtime let fireworks-ai = FireworksAi::model_name("accounts/fireworks/models/deepseek-r1-0528"); ``` ### Using Builder Pattern with Custom Settings ```rust use aisdk::{ core::DynamicModel, providers::FireworksAi, }; let fireworks-ai = FireworksAi::::builder() .model_name("accounts/fireworks/models/deepseek-r1-0528") .api_key("your-api-key") .base_url("https://api.fireworks.ai/inference/v1/") .path("https://full-url.example/v1/chat/completions") .provider_name("FireworksAi") .build()?; ``` **Warning**: When using `DynamicModel`, model capabilities are **not validated at compile time**. This means there's no guarantee the model supports requested features (e.g., tool calls, structured output). For compile-time safety, use the typed methods like `FireworksAi::models_deepseek_r1_0528()`. ## Next Steps * Take a deeper look at text generation features [Generating Text](/docs/concepts/generating-text#generate_text) / [Streaming Text](/docs/concepts/generating-text#stream_text) * Explore [Structured Output](/docs/concepts/structured-output) for reliable agent data. * Learn how to create [Custom Tools](/docs/concepts/tools). * Learn more about [Agents](/docs/concepts/agents). # Firmware (/docs/providers/firmware) AISDK provides first-class support for Firmware with fully typed model APIs. Model capabilities are enforced at compile time using Rust's type system. This prevents model capability mismatches and guarantees the selected model is valid for the task (e.g. tool calling). ## Installation Enable the Firmware provider feature: ```bash cargo add aisdk --features firmware ``` This installs AISDK with the Firmware provider enabled. Once you have enabled the Firmware provider, you can use all aisdk features with it. ## Create a Provider Instance To create a provider instance, call `Firmware::model_name()`, where **model\_name** is the Firmware model you want to use. Model names are exposed as snake-case methods. ```rust use aisdk::providers::Firmware; let firmware = Firmware::claude_haiku_4_5(); ``` This initializes the provider with: * Model: `"claude-haiku-4-5"` * API key from environment (if set with `FIRMWARE_API_KEY`) * Firmware's default base URL ([https://app.firmware.ai/api/v1](https://app.firmware.ai/api/v1)) ## Basic Text Generation Example using [LanguageModelRequest](https://docs.rs/aisdk/latest/aisdk/core/struct.LanguageModelRequest.html) for text generation. ```rust use aisdk::{ core::LanguageModelRequest, providers::Firmware, }; #[tokio::main] async fn main() -> Result<(), Box> { let firmware = Firmware::claude_haiku_4_5(); let response = LanguageModelRequest::builder() .model(firmware) .prompt("Write a short poem about Rust.") .build() .generate_text() .await?; println!("Response text: {:?}", response.text()); Ok(()) } ``` ## Provider Settings You can customize provider configuration using `Firmware::builder()` ### API Key ```rust let firmware = Firmware::::builder() .api_key("your-api-key") .build()?; ``` If not specified, AISDK uses the `FIRMWARE_API_KEY` environment variable. ### Base URL Useful when routing through a proxy, gateway, or self-hosted compatible endpoint. ```rust let firmware = Firmware::::builder() .base_url("https://app.firmware.ai/api/v1") .build()?; ``` ### Path (Full URL Override) Use `.path(...)` to override the full request URL instead of only the base URL. ```rust let firmware = Firmware::::builder() .path("https://full-url.example/v1/chat/completions") .build()?; ``` ### Provider Name For logging, analytics, and observability. ```rust let firmware = Firmware::::builder() .provider_name("Firmware") .build()?; ``` ### Full Custom Configuration Example ```rust let firmware = Firmware::::builder() .api_key("your-api-key") .base_url("https://app.firmware.ai/api/v1") .path("https://full-url.example/v1/chat/completions") .provider_name("Firmware") .build()?; ``` ## Dynamic Model Selection For runtime model selection (e.g., loading models from config files), use `DynamicModel`: ### Using model\_name() Method with Default Settings ```rust use aisdk::providers::Firmware; // Specify model as a string at runtime let firmware = Firmware::model_name("claude-haiku-4-5"); ``` ### Using Builder Pattern with Custom Settings ```rust use aisdk::{ core::DynamicModel, providers::Firmware, }; let firmware = Firmware::::builder() .model_name("claude-haiku-4-5") .api_key("your-api-key") .base_url("https://app.firmware.ai/api/v1") .path("https://full-url.example/v1/chat/completions") .provider_name("Firmware") .build()?; ``` **Warning**: When using `DynamicModel`, model capabilities are **not validated at compile time**. This means there's no guarantee the model supports requested features (e.g., tool calls, structured output). For compile-time safety, use the typed methods like `Firmware::claude_haiku_4_5()`. ## Next Steps * Take a deeper look at text generation features [Generating Text](/docs/concepts/generating-text#generate_text) / [Streaming Text](/docs/concepts/generating-text#stream_text) * Explore [Structured Output](/docs/concepts/structured-output) for reliable agent data. * Learn how to create [Custom Tools](/docs/concepts/tools). * Learn more about [Agents](/docs/concepts/agents). # Friendli (/docs/providers/friendli) AISDK provides first-class support for Friendli with fully typed model APIs. Model capabilities are enforced at compile time using Rust's type system. This prevents model capability mismatches and guarantees the selected model is valid for the task (e.g. tool calling). ## Installation Enable the Friendli provider feature: ```bash cargo add aisdk --features friendli ``` This installs AISDK with the Friendli provider enabled. Once you have enabled the Friendli provider, you can use all aisdk features with it. ## Create a Provider Instance To create a provider instance, call `Friendli::model_name()`, where **model\_name** is the Friendli model you want to use. Model names are exposed as snake-case methods. ```rust use aisdk::providers::Friendli; let friendli = Friendli::lgai_exaone_exaone_4_0_1_32b(); ``` This initializes the provider with: * Model: `"LGAI-EXAONE/EXAONE-4.0.1-32B"` * API key from environment (if set with `FRIENDLI_TOKEN`) * Friendli's default base URL ([https://api.friendli.ai/serverless/v1](https://api.friendli.ai/serverless/v1)) ## Basic Text Generation Example using [LanguageModelRequest](https://docs.rs/aisdk/latest/aisdk/core/struct.LanguageModelRequest.html) for text generation. ```rust use aisdk::{ core::LanguageModelRequest, providers::Friendli, }; #[tokio::main] async fn main() -> Result<(), Box> { let friendli = Friendli::lgai_exaone_exaone_4_0_1_32b(); let response = LanguageModelRequest::builder() .model(friendli) .prompt("Write a short poem about Rust.") .build() .generate_text() .await?; println!("Response text: {:?}", response.text()); Ok(()) } ``` ## Provider Settings You can customize provider configuration using `Friendli::builder()` ### API Key ```rust let friendli = Friendli::::builder() .api_key("your-api-key") .build()?; ``` If not specified, AISDK uses the `FRIENDLI_TOKEN` environment variable. ### Base URL Useful when routing through a proxy, gateway, or self-hosted compatible endpoint. ```rust let friendli = Friendli::::builder() .base_url("https://api.friendli.ai/serverless/v1") .build()?; ``` ### Path (Full URL Override) Use `.path(...)` to override the full request URL instead of only the base URL. ```rust let friendli = Friendli::::builder() .path("https://full-url.example/v1/chat/completions") .build()?; ``` ### Provider Name For logging, analytics, and observability. ```rust let friendli = Friendli::::builder() .provider_name("Friendli") .build()?; ``` ### Full Custom Configuration Example ```rust let friendli = Friendli::::builder() .api_key("your-api-key") .base_url("https://api.friendli.ai/serverless/v1") .path("https://full-url.example/v1/chat/completions") .provider_name("Friendli") .build()?; ``` ## Dynamic Model Selection For runtime model selection (e.g., loading models from config files), use `DynamicModel`: ### Using model\_name() Method with Default Settings ```rust use aisdk::providers::Friendli; // Specify model as a string at runtime let friendli = Friendli::model_name("LGAI-EXAONE/EXAONE-4.0.1-32B"); ``` ### Using Builder Pattern with Custom Settings ```rust use aisdk::{ core::DynamicModel, providers::Friendli, }; let friendli = Friendli::::builder() .model_name("LGAI-EXAONE/EXAONE-4.0.1-32B") .api_key("your-api-key") .base_url("https://api.friendli.ai/serverless/v1") .path("https://full-url.example/v1/chat/completions") .provider_name("Friendli") .build()?; ``` **Warning**: When using `DynamicModel`, model capabilities are **not validated at compile time**. This means there's no guarantee the model supports requested features (e.g., tool calls, structured output). For compile-time safety, use the typed methods like `Friendli::lgai_exaone_exaone_4_0_1_32b()`. ## Next Steps * Take a deeper look at text generation features [Generating Text](/docs/concepts/generating-text#generate_text) / [Streaming Text](/docs/concepts/generating-text#stream_text) * Explore [Structured Output](/docs/concepts/structured-output) for reliable agent data. * Learn how to create [Custom Tools](/docs/concepts/tools). * Learn more about [Agents](/docs/concepts/agents). # GithubCopilot (/docs/providers/github-copilot) AISDK provides first-class support for GithubCopilot with fully typed model APIs. Model capabilities are enforced at compile time using Rust's type system. This prevents model capability mismatches and guarantees the selected model is valid for the task (e.g. tool calling). ## Installation Enable the GithubCopilot provider feature: ```bash cargo add aisdk --features github-copilot ``` This installs AISDK with the GithubCopilot provider enabled. Once you have enabled the GithubCopilot provider, you can use all aisdk features with it. ## Create a Provider Instance To create a provider instance, call `GithubCopilot::model_name()`, where **model\_name** is the GithubCopilot model you want to use. Model names are exposed as snake-case methods. ```rust use aisdk::providers::GithubCopilot; let github-copilot = GithubCopilot::claude_haiku_4_5(); ``` This initializes the provider with: * Model: `"claude-haiku-4.5"` * API key from environment (if set with `GITHUB_TOKEN`) * GithubCopilot's default base URL ([https://api.githubcopilot.com](https://api.githubcopilot.com)) ## Basic Text Generation Example using [LanguageModelRequest](https://docs.rs/aisdk/latest/aisdk/core/struct.LanguageModelRequest.html) for text generation. ```rust use aisdk::{ core::LanguageModelRequest, providers::GithubCopilot, }; #[tokio::main] async fn main() -> Result<(), Box> { let github-copilot = GithubCopilot::claude_haiku_4_5(); let response = LanguageModelRequest::builder() .model(github-copilot) .prompt("Write a short poem about Rust.") .build() .generate_text() .await?; println!("Response text: {:?}", response.text()); Ok(()) } ``` ## Provider Settings You can customize provider configuration using `GithubCopilot::builder()` ### API Key ```rust let github-copilot = GithubCopilot::::builder() .api_key("your-api-key") .build()?; ``` If not specified, AISDK uses the `GITHUB_TOKEN` environment variable. ### Base URL Useful when routing through a proxy, gateway, or self-hosted compatible endpoint. ```rust let github-copilot = GithubCopilot::::builder() .base_url("https://api.githubcopilot.com") .build()?; ``` ### Path (Full URL Override) Use `.path(...)` to override the full request URL instead of only the base URL. ```rust let github-copilot = GithubCopilot::::builder() .path("https://full-url.example/v1/chat/completions") .build()?; ``` ### Provider Name For logging, analytics, and observability. ```rust let github-copilot = GithubCopilot::::builder() .provider_name("GithubCopilot") .build()?; ``` ### Full Custom Configuration Example ```rust let github-copilot = GithubCopilot::::builder() .api_key("your-api-key") .base_url("https://api.githubcopilot.com") .path("https://full-url.example/v1/chat/completions") .provider_name("GithubCopilot") .build()?; ``` ## Dynamic Model Selection For runtime model selection (e.g., loading models from config files), use `DynamicModel`: ### Using model\_name() Method with Default Settings ```rust use aisdk::providers::GithubCopilot; // Specify model as a string at runtime let github-copilot = GithubCopilot::model_name("claude-haiku-4.5"); ``` ### Using Builder Pattern with Custom Settings ```rust use aisdk::{ core::DynamicModel, providers::GithubCopilot, }; let github-copilot = GithubCopilot::::builder() .model_name("claude-haiku-4.5") .api_key("your-api-key") .base_url("https://api.githubcopilot.com") .path("https://full-url.example/v1/chat/completions") .provider_name("GithubCopilot") .build()?; ``` **Warning**: When using `DynamicModel`, model capabilities are **not validated at compile time**. This means there's no guarantee the model supports requested features (e.g., tool calls, structured output). For compile-time safety, use the typed methods like `GithubCopilot::claude_haiku_4_5()`. ## Next Steps * Take a deeper look at text generation features [Generating Text](/docs/concepts/generating-text#generate_text) / [Streaming Text](/docs/concepts/generating-text#stream_text) * Explore [Structured Output](/docs/concepts/structured-output) for reliable agent data. * Learn how to create [Custom Tools](/docs/concepts/tools). * Learn more about [Agents](/docs/concepts/agents). # GithubModels (/docs/providers/github-models) AISDK provides first-class support for GithubModels with fully typed model APIs. Model capabilities are enforced at compile time using Rust's type system. This prevents model capability mismatches and guarantees the selected model is valid for the task (e.g. tool calling). ## Installation Enable the GithubModels provider feature: ```bash cargo add aisdk --features github-models ``` This installs AISDK with the GithubModels provider enabled. Once you have enabled the GithubModels provider, you can use all aisdk features with it. ## Create a Provider Instance To create a provider instance, call `GithubModels::model_name()`, where **model\_name** is the GithubModels model you want to use. Model names are exposed as snake-case methods. ```rust use aisdk::providers::GithubModels; let github-models = GithubModels::ai21_labs_ai21_jamba_1_5_large(); ``` This initializes the provider with: * Model: `"ai21-labs/ai21-jamba-1.5-large"` * API key from environment (if set with `GITHUB_TOKEN`) * GithubModels's default base URL ([https://models.github.ai/inference](https://models.github.ai/inference)) ## Basic Text Generation Example using [LanguageModelRequest](https://docs.rs/aisdk/latest/aisdk/core/struct.LanguageModelRequest.html) for text generation. ```rust use aisdk::{ core::LanguageModelRequest, providers::GithubModels, }; #[tokio::main] async fn main() -> Result<(), Box> { let github-models = GithubModels::ai21_labs_ai21_jamba_1_5_large(); let response = LanguageModelRequest::builder() .model(github-models) .prompt("Write a short poem about Rust.") .build() .generate_text() .await?; println!("Response text: {:?}", response.text()); Ok(()) } ``` ## Provider Settings You can customize provider configuration using `GithubModels::builder()` ### API Key ```rust let github-models = GithubModels::::builder() .api_key("your-api-key") .build()?; ``` If not specified, AISDK uses the `GITHUB_TOKEN` environment variable. ### Base URL Useful when routing through a proxy, gateway, or self-hosted compatible endpoint. ```rust let github-models = GithubModels::::builder() .base_url("https://models.github.ai/inference") .build()?; ``` ### Path (Full URL Override) Use `.path(...)` to override the full request URL instead of only the base URL. ```rust let github-models = GithubModels::::builder() .path("https://full-url.example/v1/chat/completions") .build()?; ``` ### Provider Name For logging, analytics, and observability. ```rust let github-models = GithubModels::::builder() .provider_name("GithubModels") .build()?; ``` ### Full Custom Configuration Example ```rust let github-models = GithubModels::::builder() .api_key("your-api-key") .base_url("https://models.github.ai/inference") .path("https://full-url.example/v1/chat/completions") .provider_name("GithubModels") .build()?; ``` ## Dynamic Model Selection For runtime model selection (e.g., loading models from config files), use `DynamicModel`: ### Using model\_name() Method with Default Settings ```rust use aisdk::providers::GithubModels; // Specify model as a string at runtime let github-models = GithubModels::model_name("ai21-labs/ai21-jamba-1.5-large"); ``` ### Using Builder Pattern with Custom Settings ```rust use aisdk::{ core::DynamicModel, providers::GithubModels, }; let github-models = GithubModels::::builder() .model_name("ai21-labs/ai21-jamba-1.5-large") .api_key("your-api-key") .base_url("https://models.github.ai/inference") .path("https://full-url.example/v1/chat/completions") .provider_name("GithubModels") .build()?; ``` **Warning**: When using `DynamicModel`, model capabilities are **not validated at compile time**. This means there's no guarantee the model supports requested features (e.g., tool calls, structured output). For compile-time safety, use the typed methods like `GithubModels::ai21_labs_ai21_jamba_1_5_large()`. ## Next Steps * Take a deeper look at text generation features [Generating Text](/docs/concepts/generating-text#generate_text) / [Streaming Text](/docs/concepts/generating-text#stream_text) * Explore [Structured Output](/docs/concepts/structured-output) for reliable agent data. * Learn how to create [Custom Tools](/docs/concepts/tools). * Learn more about [Agents](/docs/concepts/agents). # Google (/docs/providers/google) AISDK provides first-class support for Google with fully typed model APIs. Model capabilities are enforced at compile time using Rust's type system. This prevents model capability mismatches and guarantees the selected model is valid for the task (e.g. tool calling). ## Installation Enable the Google provider feature: ```bash cargo add aisdk --features google ``` This installs AISDK with the Google provider enabled. Once you have enabled the Google provider, you can use all aisdk features with it. ## Create a Provider Instance To create a provider instance, call `Google::model_name()`, where **model\_name** is the Google model you want to use. Model names are exposed as snake-case methods. ```rust use aisdk::providers::Google; let google = Google::gemini_1_5_flash(); ``` This initializes the provider with: * Model: `"gemini-1.5-flash"` * API key from environment (if set with `GOOGLE_API_KEY`) * Google's default base URL ([https://generativelanguage.googleapis.com](https://generativelanguage.googleapis.com)) ## Basic Text Generation Example using [LanguageModelRequest](https://docs.rs/aisdk/latest/aisdk/core/struct.LanguageModelRequest.html) for text generation. ```rust use aisdk::{ core::LanguageModelRequest, providers::Google, }; #[tokio::main] async fn main() -> Result<(), Box> { let google = Google::gemini_1_5_flash(); let response = LanguageModelRequest::builder() .model(google) .prompt("Write a short poem about Rust.") .build() .generate_text() .await?; println!("Response text: {:?}", response.text()); Ok(()) } ``` ## Provider Settings You can customize provider configuration using `Google::builder()` ### API Key ```rust let google = Google::::builder() .api_key("your-api-key") .build()?; ``` If not specified, AISDK uses the `GOOGLE_API_KEY` environment variable. ### Base URL Useful when routing through a proxy, gateway, or self-hosted compatible endpoint. ```rust let google = Google::::builder() .base_url("https://generativelanguage.googleapis.com") .build()?; ``` ### Path (Full URL Override) Use `.path(...)` to override the full request URL instead of only the base URL. ```rust let google = Google::::builder() .path("https://full-url.example/v1/chat/completions") .build()?; ``` ### Provider Name For logging, analytics, and observability. ```rust let google = Google::::builder() .provider_name("Google") .build()?; ``` ### Full Custom Configuration Example ```rust let google = Google::::builder() .api_key("your-api-key") .base_url("https://generativelanguage.googleapis.com") .path("https://full-url.example/v1/chat/completions") .provider_name("Google") .build()?; ``` ## Dynamic Model Selection For runtime model selection (e.g., loading models from config files), use `DynamicModel`: ### Using model\_name() Method with Default Settings ```rust use aisdk::providers::Google; // Specify model as a string at runtime let google = Google::model_name("gemini-1.5-flash"); ``` ### Using Builder Pattern with Custom Settings ```rust use aisdk::{ core::DynamicModel, providers::Google, }; let google = Google::::builder() .model_name("gemini-1.5-flash") .api_key("your-api-key") .base_url("https://generativelanguage.googleapis.com") .path("https://full-url.example/v1/chat/completions") .provider_name("Google") .build()?; ``` **Warning**: When using `DynamicModel`, model capabilities are **not validated at compile time**. This means there's no guarantee the model supports requested features (e.g., tool calls, structured output). For compile-time safety, use the typed methods like `Google::gemini_1_5_flash()`. ## Next Steps * Take a deeper look at text generation features [Generating Text](/docs/concepts/generating-text#generate_text) / [Streaming Text](/docs/concepts/generating-text#stream_text) * Explore [Structured Output](/docs/concepts/structured-output) for reliable agent data. * Learn how to create [Custom Tools](/docs/concepts/tools). * Learn more about [Agents](/docs/concepts/agents). # Groq (/docs/providers/groq) AISDK provides first-class support for Groq with fully typed model APIs. Model capabilities are enforced at compile time using Rust's type system. This prevents model capability mismatches and guarantees the selected model is valid for the task (e.g. tool calling). ## Installation Enable the Groq provider feature: ```bash cargo add aisdk --features groq ``` This installs AISDK with the Groq provider enabled. Once you have enabled the Groq provider, you can use all aisdk features with it. ## Create a Provider Instance To create a provider instance, call `Groq::model_name()`, where **model\_name** is the Groq model you want to use. Model names are exposed as snake-case methods. ```rust use aisdk::providers::Groq; let groq = Groq::llama_3_1_8b_instant(); ``` This initializes the provider with: * Model: `"llama-3.1-8b-instant"` * API key from environment (if set with `GROQ_API_KEY`) * Groq's default base URL ([https://api.groq.com/openai/v1/](https://api.groq.com/openai/v1/)) ## Basic Text Generation Example using [LanguageModelRequest](https://docs.rs/aisdk/latest/aisdk/core/struct.LanguageModelRequest.html) for text generation. ```rust use aisdk::{ core::LanguageModelRequest, providers::Groq, }; #[tokio::main] async fn main() -> Result<(), Box> { let groq = Groq::llama_3_1_8b_instant(); let response = LanguageModelRequest::builder() .model(groq) .prompt("Write a short poem about Rust.") .build() .generate_text() .await?; println!("Response text: {:?}", response.text()); Ok(()) } ``` ## Provider Settings You can customize provider configuration using `Groq::builder()` ### API Key ```rust let groq = Groq::::builder() .api_key("your-api-key") .build()?; ``` If not specified, AISDK uses the `GROQ_API_KEY` environment variable. ### Base URL Useful when routing through a proxy, gateway, or self-hosted compatible endpoint. ```rust let groq = Groq::::builder() .base_url("https://api.groq.com/openai/v1/") .build()?; ``` ### Path (Full URL Override) Use `.path(...)` to override the full request URL instead of only the base URL. ```rust let groq = Groq::::builder() .path("https://full-url.example/v1/chat/completions") .build()?; ``` ### Provider Name For logging, analytics, and observability. ```rust let groq = Groq::::builder() .provider_name("Groq") .build()?; ``` ### Full Custom Configuration Example ```rust let groq = Groq::::builder() .api_key("your-api-key") .base_url("https://api.groq.com/openai/v1/") .path("https://full-url.example/v1/chat/completions") .provider_name("Groq") .build()?; ``` ## Dynamic Model Selection For runtime model selection (e.g., loading models from config files), use `DynamicModel`: ### Using model\_name() Method with Default Settings ```rust use aisdk::providers::Groq; // Specify model as a string at runtime let groq = Groq::model_name("llama-3.1-8b-instant"); ``` ### Using Builder Pattern with Custom Settings ```rust use aisdk::{ core::DynamicModel, providers::Groq, }; let groq = Groq::::builder() .model_name("llama-3.1-8b-instant") .api_key("your-api-key") .base_url("https://api.groq.com/openai/v1/") .path("https://full-url.example/v1/chat/completions") .provider_name("Groq") .build()?; ``` **Warning**: When using `DynamicModel`, model capabilities are **not validated at compile time**. This means there's no guarantee the model supports requested features (e.g., tool calls, structured output). For compile-time safety, use the typed methods like `Groq::llama_3_1_8b_instant()`. ## Next Steps * Take a deeper look at text generation features [Generating Text](/docs/concepts/generating-text#generate_text) / [Streaming Text](/docs/concepts/generating-text#stream_text) * Explore [Structured Output](/docs/concepts/structured-output) for reliable agent data. * Learn how to create [Custom Tools](/docs/concepts/tools). * Learn more about [Agents](/docs/concepts/agents). # Helicone (/docs/providers/helicone) AISDK provides first-class support for Helicone with fully typed model APIs. Model capabilities are enforced at compile time using Rust's type system. This prevents model capability mismatches and guarantees the selected model is valid for the task (e.g. tool calling). ## Installation Enable the Helicone provider feature: ```bash cargo add aisdk --features helicone ``` This installs AISDK with the Helicone provider enabled. Once you have enabled the Helicone provider, you can use all aisdk features with it. ## Create a Provider Instance To create a provider instance, call `Helicone::model_name()`, where **model\_name** is the Helicone model you want to use. Model names are exposed as snake-case methods. ```rust use aisdk::providers::Helicone; let helicone = Helicone::chatgpt_4o_latest(); ``` This initializes the provider with: * Model: `"chatgpt-4o-latest"` * API key from environment (if set with `HELICONE_API_KEY`) * Helicone's default base URL ([https://ai-gateway.helicone.ai/v1](https://ai-gateway.helicone.ai/v1)) ## Basic Text Generation Example using [LanguageModelRequest](https://docs.rs/aisdk/latest/aisdk/core/struct.LanguageModelRequest.html) for text generation. ```rust use aisdk::{ core::LanguageModelRequest, providers::Helicone, }; #[tokio::main] async fn main() -> Result<(), Box> { let helicone = Helicone::chatgpt_4o_latest(); let response = LanguageModelRequest::builder() .model(helicone) .prompt("Write a short poem about Rust.") .build() .generate_text() .await?; println!("Response text: {:?}", response.text()); Ok(()) } ``` ## Provider Settings You can customize provider configuration using `Helicone::builder()` ### API Key ```rust let helicone = Helicone::::builder() .api_key("your-api-key") .build()?; ``` If not specified, AISDK uses the `HELICONE_API_KEY` environment variable. ### Base URL Useful when routing through a proxy, gateway, or self-hosted compatible endpoint. ```rust let helicone = Helicone::::builder() .base_url("https://ai-gateway.helicone.ai/v1") .build()?; ``` ### Path (Full URL Override) Use `.path(...)` to override the full request URL instead of only the base URL. ```rust let helicone = Helicone::::builder() .path("https://full-url.example/v1/chat/completions") .build()?; ``` ### Provider Name For logging, analytics, and observability. ```rust let helicone = Helicone::::builder() .provider_name("Helicone") .build()?; ``` ### Full Custom Configuration Example ```rust let helicone = Helicone::::builder() .api_key("your-api-key") .base_url("https://ai-gateway.helicone.ai/v1") .path("https://full-url.example/v1/chat/completions") .provider_name("Helicone") .build()?; ``` ## Dynamic Model Selection For runtime model selection (e.g., loading models from config files), use `DynamicModel`: ### Using model\_name() Method with Default Settings ```rust use aisdk::providers::Helicone; // Specify model as a string at runtime let helicone = Helicone::model_name("chatgpt-4o-latest"); ``` ### Using Builder Pattern with Custom Settings ```rust use aisdk::{ core::DynamicModel, providers::Helicone, }; let helicone = Helicone::::builder() .model_name("chatgpt-4o-latest") .api_key("your-api-key") .base_url("https://ai-gateway.helicone.ai/v1") .path("https://full-url.example/v1/chat/completions") .provider_name("Helicone") .build()?; ``` **Warning**: When using `DynamicModel`, model capabilities are **not validated at compile time**. This means there's no guarantee the model supports requested features (e.g., tool calls, structured output). For compile-time safety, use the typed methods like `Helicone::chatgpt_4o_latest()`. ## Next Steps * Take a deeper look at text generation features [Generating Text](/docs/concepts/generating-text#generate_text) / [Streaming Text](/docs/concepts/generating-text#stream_text) * Explore [Structured Output](/docs/concepts/structured-output) for reliable agent data. * Learn how to create [Custom Tools](/docs/concepts/tools). * Learn more about [Agents](/docs/concepts/agents). # Huggingface (/docs/providers/huggingface) AISDK provides first-class support for Huggingface with fully typed model APIs. Model capabilities are enforced at compile time using Rust's type system. This prevents model capability mismatches and guarantees the selected model is valid for the task (e.g. tool calling). ## Installation Enable the Huggingface provider feature: ```bash cargo add aisdk --features huggingface ``` This installs AISDK with the Huggingface provider enabled. Once you have enabled the Huggingface provider, you can use all aisdk features with it. ## Create a Provider Instance To create a provider instance, call `Huggingface::model_name()`, where **model\_name** is the Huggingface model you want to use. Model names are exposed as snake-case methods. ```rust use aisdk::providers::Huggingface; let huggingface = Huggingface::minimaxai_minimax_m2_1(); ``` This initializes the provider with: * Model: `"MiniMaxAI/MiniMax-M2.1"` * API key from environment (if set with `HF_TOKEN`) * Huggingface's default base URL ([https://router.huggingface.co/v1](https://router.huggingface.co/v1)) ## Basic Text Generation Example using [LanguageModelRequest](https://docs.rs/aisdk/latest/aisdk/core/struct.LanguageModelRequest.html) for text generation. ```rust use aisdk::{ core::LanguageModelRequest, providers::Huggingface, }; #[tokio::main] async fn main() -> Result<(), Box> { let huggingface = Huggingface::minimaxai_minimax_m2_1(); let response = LanguageModelRequest::builder() .model(huggingface) .prompt("Write a short poem about Rust.") .build() .generate_text() .await?; println!("Response text: {:?}", response.text()); Ok(()) } ``` ## Provider Settings You can customize provider configuration using `Huggingface::builder()` ### API Key ```rust let huggingface = Huggingface::::builder() .api_key("your-api-key") .build()?; ``` If not specified, AISDK uses the `HF_TOKEN` environment variable. ### Base URL Useful when routing through a proxy, gateway, or self-hosted compatible endpoint. ```rust let huggingface = Huggingface::::builder() .base_url("https://router.huggingface.co/v1") .build()?; ``` ### Path (Full URL Override) Use `.path(...)` to override the full request URL instead of only the base URL. ```rust let huggingface = Huggingface::::builder() .path("https://full-url.example/v1/chat/completions") .build()?; ``` ### Provider Name For logging, analytics, and observability. ```rust let huggingface = Huggingface::::builder() .provider_name("Huggingface") .build()?; ``` ### Full Custom Configuration Example ```rust let huggingface = Huggingface::::builder() .api_key("your-api-key") .base_url("https://router.huggingface.co/v1") .path("https://full-url.example/v1/chat/completions") .provider_name("Huggingface") .build()?; ``` ## Dynamic Model Selection For runtime model selection (e.g., loading models from config files), use `DynamicModel`: ### Using model\_name() Method with Default Settings ```rust use aisdk::providers::Huggingface; // Specify model as a string at runtime let huggingface = Huggingface::model_name("MiniMaxAI/MiniMax-M2.1"); ``` ### Using Builder Pattern with Custom Settings ```rust use aisdk::{ core::DynamicModel, providers::Huggingface, }; let huggingface = Huggingface::::builder() .model_name("MiniMaxAI/MiniMax-M2.1") .api_key("your-api-key") .base_url("https://router.huggingface.co/v1") .path("https://full-url.example/v1/chat/completions") .provider_name("Huggingface") .build()?; ``` **Warning**: When using `DynamicModel`, model capabilities are **not validated at compile time**. This means there's no guarantee the model supports requested features (e.g., tool calls, structured output). For compile-time safety, use the typed methods like `Huggingface::minimaxai_minimax_m2_1()`. ## Next Steps * Take a deeper look at text generation features [Generating Text](/docs/concepts/generating-text#generate_text) / [Streaming Text](/docs/concepts/generating-text#stream_text) * Explore [Structured Output](/docs/concepts/structured-output) for reliable agent data. * Learn how to create [Custom Tools](/docs/concepts/tools). * Learn more about [Agents](/docs/concepts/agents). # Iflowcn (/docs/providers/iflowcn) AISDK provides first-class support for Iflowcn with fully typed model APIs. Model capabilities are enforced at compile time using Rust's type system. This prevents model capability mismatches and guarantees the selected model is valid for the task (e.g. tool calling). ## Installation Enable the Iflowcn provider feature: ```bash cargo add aisdk --features iflowcn ``` This installs AISDK with the Iflowcn provider enabled. Once you have enabled the Iflowcn provider, you can use all aisdk features with it. ## Create a Provider Instance To create a provider instance, call `Iflowcn::model_name()`, where **model\_name** is the Iflowcn model you want to use. Model names are exposed as snake-case methods. ```rust use aisdk::providers::Iflowcn; let iflowcn = Iflowcn::deepseek_r1(); ``` This initializes the provider with: * Model: `"deepseek-r1"` * API key from environment (if set with `IFLOW_API_KEY`) * Iflowcn's default base URL ([https://apis.iflow.cn/v1](https://apis.iflow.cn/v1)) ## Basic Text Generation Example using [LanguageModelRequest](https://docs.rs/aisdk/latest/aisdk/core/struct.LanguageModelRequest.html) for text generation. ```rust use aisdk::{ core::LanguageModelRequest, providers::Iflowcn, }; #[tokio::main] async fn main() -> Result<(), Box> { let iflowcn = Iflowcn::deepseek_r1(); let response = LanguageModelRequest::builder() .model(iflowcn) .prompt("Write a short poem about Rust.") .build() .generate_text() .await?; println!("Response text: {:?}", response.text()); Ok(()) } ``` ## Provider Settings You can customize provider configuration using `Iflowcn::builder()` ### API Key ```rust let iflowcn = Iflowcn::::builder() .api_key("your-api-key") .build()?; ``` If not specified, AISDK uses the `IFLOW_API_KEY` environment variable. ### Base URL Useful when routing through a proxy, gateway, or self-hosted compatible endpoint. ```rust let iflowcn = Iflowcn::::builder() .base_url("https://apis.iflow.cn/v1") .build()?; ``` ### Path (Full URL Override) Use `.path(...)` to override the full request URL instead of only the base URL. ```rust let iflowcn = Iflowcn::::builder() .path("https://full-url.example/v1/chat/completions") .build()?; ``` ### Provider Name For logging, analytics, and observability. ```rust let iflowcn = Iflowcn::::builder() .provider_name("Iflowcn") .build()?; ``` ### Full Custom Configuration Example ```rust let iflowcn = Iflowcn::::builder() .api_key("your-api-key") .base_url("https://apis.iflow.cn/v1") .path("https://full-url.example/v1/chat/completions") .provider_name("Iflowcn") .build()?; ``` ## Dynamic Model Selection For runtime model selection (e.g., loading models from config files), use `DynamicModel`: ### Using model\_name() Method with Default Settings ```rust use aisdk::providers::Iflowcn; // Specify model as a string at runtime let iflowcn = Iflowcn::model_name("deepseek-r1"); ``` ### Using Builder Pattern with Custom Settings ```rust use aisdk::{ core::DynamicModel, providers::Iflowcn, }; let iflowcn = Iflowcn::::builder() .model_name("deepseek-r1") .api_key("your-api-key") .base_url("https://apis.iflow.cn/v1") .path("https://full-url.example/v1/chat/completions") .provider_name("Iflowcn") .build()?; ``` **Warning**: When using `DynamicModel`, model capabilities are **not validated at compile time**. This means there's no guarantee the model supports requested features (e.g., tool calls, structured output). For compile-time safety, use the typed methods like `Iflowcn::deepseek_r1()`. ## Next Steps * Take a deeper look at text generation features [Generating Text](/docs/concepts/generating-text#generate_text) / [Streaming Text](/docs/concepts/generating-text#stream_text) * Explore [Structured Output](/docs/concepts/structured-output) for reliable agent data. * Learn how to create [Custom Tools](/docs/concepts/tools). * Learn more about [Agents](/docs/concepts/agents). # Inception (/docs/providers/inception) AISDK provides first-class support for Inception with fully typed model APIs. Model capabilities are enforced at compile time using Rust's type system. This prevents model capability mismatches and guarantees the selected model is valid for the task (e.g. tool calling). ## Installation Enable the Inception provider feature: ```bash cargo add aisdk --features inception ``` This installs AISDK with the Inception provider enabled. Once you have enabled the Inception provider, you can use all aisdk features with it. ## Create a Provider Instance To create a provider instance, call `Inception::model_name()`, where **model\_name** is the Inception model you want to use. Model names are exposed as snake-case methods. ```rust use aisdk::providers::Inception; let inception = Inception::mercury(); ``` This initializes the provider with: * Model: `"mercury"` * API key from environment (if set with `INCEPTION_API_KEY`) * Inception's default base URL ([https://api.inceptionlabs.ai/v1/](https://api.inceptionlabs.ai/v1/)) ## Basic Text Generation Example using [LanguageModelRequest](https://docs.rs/aisdk/latest/aisdk/core/struct.LanguageModelRequest.html) for text generation. ```rust use aisdk::{ core::LanguageModelRequest, providers::Inception, }; #[tokio::main] async fn main() -> Result<(), Box> { let inception = Inception::mercury(); let response = LanguageModelRequest::builder() .model(inception) .prompt("Write a short poem about Rust.") .build() .generate_text() .await?; println!("Response text: {:?}", response.text()); Ok(()) } ``` ## Provider Settings You can customize provider configuration using `Inception::builder()` ### API Key ```rust let inception = Inception::::builder() .api_key("your-api-key") .build()?; ``` If not specified, AISDK uses the `INCEPTION_API_KEY` environment variable. ### Base URL Useful when routing through a proxy, gateway, or self-hosted compatible endpoint. ```rust let inception = Inception::::builder() .base_url("https://api.inceptionlabs.ai/v1/") .build()?; ``` ### Path (Full URL Override) Use `.path(...)` to override the full request URL instead of only the base URL. ```rust let inception = Inception::::builder() .path("https://full-url.example/v1/chat/completions") .build()?; ``` ### Provider Name For logging, analytics, and observability. ```rust let inception = Inception::::builder() .provider_name("Inception") .build()?; ``` ### Full Custom Configuration Example ```rust let inception = Inception::::builder() .api_key("your-api-key") .base_url("https://api.inceptionlabs.ai/v1/") .path("https://full-url.example/v1/chat/completions") .provider_name("Inception") .build()?; ``` ## Dynamic Model Selection For runtime model selection (e.g., loading models from config files), use `DynamicModel`: ### Using model\_name() Method with Default Settings ```rust use aisdk::providers::Inception; // Specify model as a string at runtime let inception = Inception::model_name("mercury"); ``` ### Using Builder Pattern with Custom Settings ```rust use aisdk::{ core::DynamicModel, providers::Inception, }; let inception = Inception::::builder() .model_name("mercury") .api_key("your-api-key") .base_url("https://api.inceptionlabs.ai/v1/") .path("https://full-url.example/v1/chat/completions") .provider_name("Inception") .build()?; ``` **Warning**: When using `DynamicModel`, model capabilities are **not validated at compile time**. This means there's no guarantee the model supports requested features (e.g., tool calls, structured output). For compile-time safety, use the typed methods like `Inception::mercury()`. ## Next Steps * Take a deeper look at text generation features [Generating Text](/docs/concepts/generating-text#generate_text) / [Streaming Text](/docs/concepts/generating-text#stream_text) * Explore [Structured Output](/docs/concepts/structured-output) for reliable agent data. * Learn how to create [Custom Tools](/docs/concepts/tools). * Learn more about [Agents](/docs/concepts/agents). # Inference (/docs/providers/inference) AISDK provides first-class support for Inference with fully typed model APIs. Model capabilities are enforced at compile time using Rust's type system. This prevents model capability mismatches and guarantees the selected model is valid for the task (e.g. tool calling). ## Installation Enable the Inference provider feature: ```bash cargo add aisdk --features inference ``` This installs AISDK with the Inference provider enabled. Once you have enabled the Inference provider, you can use all aisdk features with it. ## Create a Provider Instance To create a provider instance, call `Inference::model_name()`, where **model\_name** is the Inference model you want to use. Model names are exposed as snake-case methods. ```rust use aisdk::providers::Inference; let inference = Inference::google_gemma_3(); ``` This initializes the provider with: * Model: `"google/gemma-3"` * API key from environment (if set with `INFERENCE_API_KEY`) * Inference's default base URL ([https://inference.net/v1](https://inference.net/v1)) ## Basic Text Generation Example using [LanguageModelRequest](https://docs.rs/aisdk/latest/aisdk/core/struct.LanguageModelRequest.html) for text generation. ```rust use aisdk::{ core::LanguageModelRequest, providers::Inference, }; #[tokio::main] async fn main() -> Result<(), Box> { let inference = Inference::google_gemma_3(); let response = LanguageModelRequest::builder() .model(inference) .prompt("Write a short poem about Rust.") .build() .generate_text() .await?; println!("Response text: {:?}", response.text()); Ok(()) } ``` ## Provider Settings You can customize provider configuration using `Inference::builder()` ### API Key ```rust let inference = Inference::::builder() .api_key("your-api-key") .build()?; ``` If not specified, AISDK uses the `INFERENCE_API_KEY` environment variable. ### Base URL Useful when routing through a proxy, gateway, or self-hosted compatible endpoint. ```rust let inference = Inference::::builder() .base_url("https://inference.net/v1") .build()?; ``` ### Path (Full URL Override) Use `.path(...)` to override the full request URL instead of only the base URL. ```rust let inference = Inference::::builder() .path("https://full-url.example/v1/chat/completions") .build()?; ``` ### Provider Name For logging, analytics, and observability. ```rust let inference = Inference::::builder() .provider_name("Inference") .build()?; ``` ### Full Custom Configuration Example ```rust let inference = Inference::::builder() .api_key("your-api-key") .base_url("https://inference.net/v1") .path("https://full-url.example/v1/chat/completions") .provider_name("Inference") .build()?; ``` ## Dynamic Model Selection For runtime model selection (e.g., loading models from config files), use `DynamicModel`: ### Using model\_name() Method with Default Settings ```rust use aisdk::providers::Inference; // Specify model as a string at runtime let inference = Inference::model_name("google/gemma-3"); ``` ### Using Builder Pattern with Custom Settings ```rust use aisdk::{ core::DynamicModel, providers::Inference, }; let inference = Inference::::builder() .model_name("google/gemma-3") .api_key("your-api-key") .base_url("https://inference.net/v1") .path("https://full-url.example/v1/chat/completions") .provider_name("Inference") .build()?; ``` **Warning**: When using `DynamicModel`, model capabilities are **not validated at compile time**. This means there's no guarantee the model supports requested features (e.g., tool calls, structured output). For compile-time safety, use the typed methods like `Inference::google_gemma_3()`. ## Next Steps * Take a deeper look at text generation features [Generating Text](/docs/concepts/generating-text#generate_text) / [Streaming Text](/docs/concepts/generating-text#stream_text) * Explore [Structured Output](/docs/concepts/structured-output) for reliable agent data. * Learn how to create [Custom Tools](/docs/concepts/tools). * Learn more about [Agents](/docs/concepts/agents). # IoNet (/docs/providers/io-net) AISDK provides first-class support for IoNet with fully typed model APIs. Model capabilities are enforced at compile time using Rust's type system. This prevents model capability mismatches and guarantees the selected model is valid for the task (e.g. tool calling). ## Installation Enable the IoNet provider feature: ```bash cargo add aisdk --features io-net ``` This installs AISDK with the IoNet provider enabled. Once you have enabled the IoNet provider, you can use all aisdk features with it. ## Create a Provider Instance To create a provider instance, call `IoNet::model_name()`, where **model\_name** is the IoNet model you want to use. Model names are exposed as snake-case methods. ```rust use aisdk::providers::IoNet; let io-net = IoNet::intel_qwen3_coder_480b_a35b_instruct_int4_mixed_ar(); ``` This initializes the provider with: * Model: `"Intel/Qwen3-Coder-480B-A35B-Instruct-int4-mixed-ar"` * API key from environment (if set with `IOINTELLIGENCE_API_KEY`) * IoNet's default base URL ([https://api.intelligence.io.solutions/api/v1](https://api.intelligence.io.solutions/api/v1)) ## Basic Text Generation Example using [LanguageModelRequest](https://docs.rs/aisdk/latest/aisdk/core/struct.LanguageModelRequest.html) for text generation. ```rust use aisdk::{ core::LanguageModelRequest, providers::IoNet, }; #[tokio::main] async fn main() -> Result<(), Box> { let io-net = IoNet::intel_qwen3_coder_480b_a35b_instruct_int4_mixed_ar(); let response = LanguageModelRequest::builder() .model(io-net) .prompt("Write a short poem about Rust.") .build() .generate_text() .await?; println!("Response text: {:?}", response.text()); Ok(()) } ``` ## Provider Settings You can customize provider configuration using `IoNet::builder()` ### API Key ```rust let io-net = IoNet::::builder() .api_key("your-api-key") .build()?; ``` If not specified, AISDK uses the `IOINTELLIGENCE_API_KEY` environment variable. ### Base URL Useful when routing through a proxy, gateway, or self-hosted compatible endpoint. ```rust let io-net = IoNet::::builder() .base_url("https://api.intelligence.io.solutions/api/v1") .build()?; ``` ### Path (Full URL Override) Use `.path(...)` to override the full request URL instead of only the base URL. ```rust let io-net = IoNet::::builder() .path("https://full-url.example/v1/chat/completions") .build()?; ``` ### Provider Name For logging, analytics, and observability. ```rust let io-net = IoNet::::builder() .provider_name("IoNet") .build()?; ``` ### Full Custom Configuration Example ```rust let io-net = IoNet::::builder() .api_key("your-api-key") .base_url("https://api.intelligence.io.solutions/api/v1") .path("https://full-url.example/v1/chat/completions") .provider_name("IoNet") .build()?; ``` ## Dynamic Model Selection For runtime model selection (e.g., loading models from config files), use `DynamicModel`: ### Using model\_name() Method with Default Settings ```rust use aisdk::providers::IoNet; // Specify model as a string at runtime let io-net = IoNet::model_name("Intel/Qwen3-Coder-480B-A35B-Instruct-int4-mixed-ar"); ``` ### Using Builder Pattern with Custom Settings ```rust use aisdk::{ core::DynamicModel, providers::IoNet, }; let io-net = IoNet::::builder() .model_name("Intel/Qwen3-Coder-480B-A35B-Instruct-int4-mixed-ar") .api_key("your-api-key") .base_url("https://api.intelligence.io.solutions/api/v1") .path("https://full-url.example/v1/chat/completions") .provider_name("IoNet") .build()?; ``` **Warning**: When using `DynamicModel`, model capabilities are **not validated at compile time**. This means there's no guarantee the model supports requested features (e.g., tool calls, structured output). For compile-time safety, use the typed methods like `IoNet::intel_qwen3_coder_480b_a35b_instruct_int4_mixed_ar()`. ## Next Steps * Take a deeper look at text generation features [Generating Text](/docs/concepts/generating-text#generate_text) / [Streaming Text](/docs/concepts/generating-text#stream_text) * Explore [Structured Output](/docs/concepts/structured-output) for reliable agent data. * Learn how to create [Custom Tools](/docs/concepts/tools). * Learn more about [Agents](/docs/concepts/agents). # Jiekou (/docs/providers/jiekou) AISDK provides first-class support for Jiekou with fully typed model APIs. Model capabilities are enforced at compile time using Rust's type system. This prevents model capability mismatches and guarantees the selected model is valid for the task (e.g. tool calling). ## Installation Enable the Jiekou provider feature: ```bash cargo add aisdk --features jiekou ``` This installs AISDK with the Jiekou provider enabled. Once you have enabled the Jiekou provider, you can use all aisdk features with it. ## Create a Provider Instance To create a provider instance, call `Jiekou::model_name()`, where **model\_name** is the Jiekou model you want to use. Model names are exposed as snake-case methods. ```rust use aisdk::providers::Jiekou; let jiekou = Jiekou::baidu_ernie_4_5_300b_a47b_paddle(); ``` This initializes the provider with: * Model: `"baidu/ernie-4.5-300b-a47b-paddle"` * API key from environment (if set with `JIEKOU_API_KEY`) * Jiekou's default base URL ([https://api.jiekou.ai/openai](https://api.jiekou.ai/openai)) ## Basic Text Generation Example using [LanguageModelRequest](https://docs.rs/aisdk/latest/aisdk/core/struct.LanguageModelRequest.html) for text generation. ```rust use aisdk::{ core::LanguageModelRequest, providers::Jiekou, }; #[tokio::main] async fn main() -> Result<(), Box> { let jiekou = Jiekou::baidu_ernie_4_5_300b_a47b_paddle(); let response = LanguageModelRequest::builder() .model(jiekou) .prompt("Write a short poem about Rust.") .build() .generate_text() .await?; println!("Response text: {:?}", response.text()); Ok(()) } ``` ## Provider Settings You can customize provider configuration using `Jiekou::builder()` ### API Key ```rust let jiekou = Jiekou::::builder() .api_key("your-api-key") .build()?; ``` If not specified, AISDK uses the `JIEKOU_API_KEY` environment variable. ### Base URL Useful when routing through a proxy, gateway, or self-hosted compatible endpoint. ```rust let jiekou = Jiekou::::builder() .base_url("https://api.jiekou.ai/openai") .build()?; ``` ### Path (Full URL Override) Use `.path(...)` to override the full request URL instead of only the base URL. ```rust let jiekou = Jiekou::::builder() .path("https://full-url.example/v1/chat/completions") .build()?; ``` ### Provider Name For logging, analytics, and observability. ```rust let jiekou = Jiekou::::builder() .provider_name("Jiekou") .build()?; ``` ### Full Custom Configuration Example ```rust let jiekou = Jiekou::::builder() .api_key("your-api-key") .base_url("https://api.jiekou.ai/openai") .path("https://full-url.example/v1/chat/completions") .provider_name("Jiekou") .build()?; ``` ## Dynamic Model Selection For runtime model selection (e.g., loading models from config files), use `DynamicModel`: ### Using model\_name() Method with Default Settings ```rust use aisdk::providers::Jiekou; // Specify model as a string at runtime let jiekou = Jiekou::model_name("baidu/ernie-4.5-300b-a47b-paddle"); ``` ### Using Builder Pattern with Custom Settings ```rust use aisdk::{ core::DynamicModel, providers::Jiekou, }; let jiekou = Jiekou::::builder() .model_name("baidu/ernie-4.5-300b-a47b-paddle") .api_key("your-api-key") .base_url("https://api.jiekou.ai/openai") .path("https://full-url.example/v1/chat/completions") .provider_name("Jiekou") .build()?; ``` **Warning**: When using `DynamicModel`, model capabilities are **not validated at compile time**. This means there's no guarantee the model supports requested features (e.g., tool calls, structured output). For compile-time safety, use the typed methods like `Jiekou::baidu_ernie_4_5_300b_a47b_paddle()`. ## Next Steps * Take a deeper look at text generation features [Generating Text](/docs/concepts/generating-text#generate_text) / [Streaming Text](/docs/concepts/generating-text#stream_text) * Explore [Structured Output](/docs/concepts/structured-output) for reliable agent data. * Learn how to create [Custom Tools](/docs/concepts/tools). * Learn more about [Agents](/docs/concepts/agents). # KuaeCloudCodingPlan (/docs/providers/kuae-cloud-coding-plan) AISDK provides first-class support for KuaeCloudCodingPlan with fully typed model APIs. Model capabilities are enforced at compile time using Rust's type system. This prevents model capability mismatches and guarantees the selected model is valid for the task (e.g. tool calling). ## Installation Enable the KuaeCloudCodingPlan provider feature: ```bash cargo add aisdk --features kuae-cloud-coding-plan ``` This installs AISDK with the KuaeCloudCodingPlan provider enabled. Once you have enabled the KuaeCloudCodingPlan provider, you can use all aisdk features with it. ## Create a Provider Instance To create a provider instance, call `KuaeCloudCodingPlan::model_name()`, where **model\_name** is the KuaeCloudCodingPlan model you want to use. Model names are exposed as snake-case methods. ```rust use aisdk::providers::KuaeCloudCodingPlan; let kuae-cloud-coding-plan = KuaeCloudCodingPlan::glm_4_7(); ``` This initializes the provider with: * Model: `"GLM-4.7"` * API key from environment (if set with `KUAE_API_KEY`) * KuaeCloudCodingPlan's default base URL ([https://coding-plan-endpoint.kuaecloud.net/v1](https://coding-plan-endpoint.kuaecloud.net/v1)) ## Basic Text Generation Example using [LanguageModelRequest](https://docs.rs/aisdk/latest/aisdk/core/struct.LanguageModelRequest.html) for text generation. ```rust use aisdk::{ core::LanguageModelRequest, providers::KuaeCloudCodingPlan, }; #[tokio::main] async fn main() -> Result<(), Box> { let kuae-cloud-coding-plan = KuaeCloudCodingPlan::glm_4_7(); let response = LanguageModelRequest::builder() .model(kuae-cloud-coding-plan) .prompt("Write a short poem about Rust.") .build() .generate_text() .await?; println!("Response text: {:?}", response.text()); Ok(()) } ``` ## Provider Settings You can customize provider configuration using `KuaeCloudCodingPlan::builder()` ### API Key ```rust let kuae-cloud-coding-plan = KuaeCloudCodingPlan::::builder() .api_key("your-api-key") .build()?; ``` If not specified, AISDK uses the `KUAE_API_KEY` environment variable. ### Base URL Useful when routing through a proxy, gateway, or self-hosted compatible endpoint. ```rust let kuae-cloud-coding-plan = KuaeCloudCodingPlan::::builder() .base_url("https://coding-plan-endpoint.kuaecloud.net/v1") .build()?; ``` ### Path (Full URL Override) Use `.path(...)` to override the full request URL instead of only the base URL. ```rust let kuae-cloud-coding-plan = KuaeCloudCodingPlan::::builder() .path("https://full-url.example/v1/chat/completions") .build()?; ``` ### Provider Name For logging, analytics, and observability. ```rust let kuae-cloud-coding-plan = KuaeCloudCodingPlan::::builder() .provider_name("KuaeCloudCodingPlan") .build()?; ``` ### Full Custom Configuration Example ```rust let kuae-cloud-coding-plan = KuaeCloudCodingPlan::::builder() .api_key("your-api-key") .base_url("https://coding-plan-endpoint.kuaecloud.net/v1") .path("https://full-url.example/v1/chat/completions") .provider_name("KuaeCloudCodingPlan") .build()?; ``` ## Dynamic Model Selection For runtime model selection (e.g., loading models from config files), use `DynamicModel`: ### Using model\_name() Method with Default Settings ```rust use aisdk::providers::KuaeCloudCodingPlan; // Specify model as a string at runtime let kuae-cloud-coding-plan = KuaeCloudCodingPlan::model_name("GLM-4.7"); ``` ### Using Builder Pattern with Custom Settings ```rust use aisdk::{ core::DynamicModel, providers::KuaeCloudCodingPlan, }; let kuae-cloud-coding-plan = KuaeCloudCodingPlan::::builder() .model_name("GLM-4.7") .api_key("your-api-key") .base_url("https://coding-plan-endpoint.kuaecloud.net/v1") .path("https://full-url.example/v1/chat/completions") .provider_name("KuaeCloudCodingPlan") .build()?; ``` **Warning**: When using `DynamicModel`, model capabilities are **not validated at compile time**. This means there's no guarantee the model supports requested features (e.g., tool calls, structured output). For compile-time safety, use the typed methods like `KuaeCloudCodingPlan::glm_4_7()`. ## Next Steps * Take a deeper look at text generation features [Generating Text](/docs/concepts/generating-text#generate_text) / [Streaming Text](/docs/concepts/generating-text#stream_text) * Explore [Structured Output](/docs/concepts/structured-output) for reliable agent data. * Learn how to create [Custom Tools](/docs/concepts/tools). * Learn more about [Agents](/docs/concepts/agents). # Llama (/docs/providers/llama) AISDK provides first-class support for Llama with fully typed model APIs. Model capabilities are enforced at compile time using Rust's type system. This prevents model capability mismatches and guarantees the selected model is valid for the task (e.g. tool calling). ## Installation Enable the Llama provider feature: ```bash cargo add aisdk --features llama ``` This installs AISDK with the Llama provider enabled. Once you have enabled the Llama provider, you can use all aisdk features with it. ## Create a Provider Instance To create a provider instance, call `Llama::model_name()`, where **model\_name** is the Llama model you want to use. Model names are exposed as snake-case methods. ```rust use aisdk::providers::Llama; let llama = Llama::cerebras_llama_4_maverick_17b_128e_instruct(); ``` This initializes the provider with: * Model: `"cerebras-llama-4-maverick-17b-128e-instruct"` * API key from environment (if set with `LLAMA_API_KEY`) * Llama's default base URL ([https://api.llama.com/compat/v1/](https://api.llama.com/compat/v1/)) ## Basic Text Generation Example using [LanguageModelRequest](https://docs.rs/aisdk/latest/aisdk/core/struct.LanguageModelRequest.html) for text generation. ```rust use aisdk::{ core::LanguageModelRequest, providers::Llama, }; #[tokio::main] async fn main() -> Result<(), Box> { let llama = Llama::cerebras_llama_4_maverick_17b_128e_instruct(); let response = LanguageModelRequest::builder() .model(llama) .prompt("Write a short poem about Rust.") .build() .generate_text() .await?; println!("Response text: {:?}", response.text()); Ok(()) } ``` ## Provider Settings You can customize provider configuration using `Llama::builder()` ### API Key ```rust let llama = Llama::::builder() .api_key("your-api-key") .build()?; ``` If not specified, AISDK uses the `LLAMA_API_KEY` environment variable. ### Base URL Useful when routing through a proxy, gateway, or self-hosted compatible endpoint. ```rust let llama = Llama::::builder() .base_url("https://api.llama.com/compat/v1/") .build()?; ``` ### Path (Full URL Override) Use `.path(...)` to override the full request URL instead of only the base URL. ```rust let llama = Llama::::builder() .path("https://full-url.example/v1/chat/completions") .build()?; ``` ### Provider Name For logging, analytics, and observability. ```rust let llama = Llama::::builder() .provider_name("Llama") .build()?; ``` ### Full Custom Configuration Example ```rust let llama = Llama::::builder() .api_key("your-api-key") .base_url("https://api.llama.com/compat/v1/") .path("https://full-url.example/v1/chat/completions") .provider_name("Llama") .build()?; ``` ## Dynamic Model Selection For runtime model selection (e.g., loading models from config files), use `DynamicModel`: ### Using model\_name() Method with Default Settings ```rust use aisdk::providers::Llama; // Specify model as a string at runtime let llama = Llama::model_name("cerebras-llama-4-maverick-17b-128e-instruct"); ``` ### Using Builder Pattern with Custom Settings ```rust use aisdk::{ core::DynamicModel, providers::Llama, }; let llama = Llama::::builder() .model_name("cerebras-llama-4-maverick-17b-128e-instruct") .api_key("your-api-key") .base_url("https://api.llama.com/compat/v1/") .path("https://full-url.example/v1/chat/completions") .provider_name("Llama") .build()?; ``` **Warning**: When using `DynamicModel`, model capabilities are **not validated at compile time**. This means there's no guarantee the model supports requested features (e.g., tool calls, structured output). For compile-time safety, use the typed methods like `Llama::cerebras_llama_4_maverick_17b_128e_instruct()`. ## Next Steps * Take a deeper look at text generation features [Generating Text](/docs/concepts/generating-text#generate_text) / [Streaming Text](/docs/concepts/generating-text#stream_text) * Explore [Structured Output](/docs/concepts/structured-output) for reliable agent data. * Learn how to create [Custom Tools](/docs/concepts/tools). * Learn more about [Agents](/docs/concepts/agents). # Lmstudio (/docs/providers/lmstudio) AISDK provides first-class support for Lmstudio with fully typed model APIs. Model capabilities are enforced at compile time using Rust's type system. This prevents model capability mismatches and guarantees the selected model is valid for the task (e.g. tool calling). ## Installation Enable the Lmstudio provider feature: ```bash cargo add aisdk --features lmstudio ``` This installs AISDK with the Lmstudio provider enabled. Once you have enabled the Lmstudio provider, you can use all aisdk features with it. ## Create a Provider Instance To create a provider instance, call `Lmstudio::model_name()`, where **model\_name** is the Lmstudio model you want to use. Model names are exposed as snake-case methods. ```rust use aisdk::providers::Lmstudio; let lmstudio = Lmstudio::openai_gpt_oss_20b(); ``` This initializes the provider with: * Model: `"openai/gpt-oss-20b"` * API key from environment (if set with `LMSTUDIO_API_KEY`) * Lmstudio's default base URL ([http://127.0.0.1:1234/v1](http://127.0.0.1:1234/v1)) ## Basic Text Generation Example using [LanguageModelRequest](https://docs.rs/aisdk/latest/aisdk/core/struct.LanguageModelRequest.html) for text generation. ```rust use aisdk::{ core::LanguageModelRequest, providers::Lmstudio, }; #[tokio::main] async fn main() -> Result<(), Box> { let lmstudio = Lmstudio::openai_gpt_oss_20b(); let response = LanguageModelRequest::builder() .model(lmstudio) .prompt("Write a short poem about Rust.") .build() .generate_text() .await?; println!("Response text: {:?}", response.text()); Ok(()) } ``` ## Provider Settings You can customize provider configuration using `Lmstudio::builder()` ### API Key ```rust let lmstudio = Lmstudio::::builder() .api_key("your-api-key") .build()?; ``` If not specified, AISDK uses the `LMSTUDIO_API_KEY` environment variable. ### Base URL Useful when routing through a proxy, gateway, or self-hosted compatible endpoint. ```rust let lmstudio = Lmstudio::::builder() .base_url("http://127.0.0.1:1234/v1") .build()?; ``` ### Path (Full URL Override) Use `.path(...)` to override the full request URL instead of only the base URL. ```rust let lmstudio = Lmstudio::::builder() .path("https://full-url.example/v1/chat/completions") .build()?; ``` ### Provider Name For logging, analytics, and observability. ```rust let lmstudio = Lmstudio::::builder() .provider_name("Lmstudio") .build()?; ``` ### Full Custom Configuration Example ```rust let lmstudio = Lmstudio::::builder() .api_key("your-api-key") .base_url("http://127.0.0.1:1234/v1") .path("https://full-url.example/v1/chat/completions") .provider_name("Lmstudio") .build()?; ``` ## Dynamic Model Selection For runtime model selection (e.g., loading models from config files), use `DynamicModel`: ### Using model\_name() Method with Default Settings ```rust use aisdk::providers::Lmstudio; // Specify model as a string at runtime let lmstudio = Lmstudio::model_name("openai/gpt-oss-20b"); ``` ### Using Builder Pattern with Custom Settings ```rust use aisdk::{ core::DynamicModel, providers::Lmstudio, }; let lmstudio = Lmstudio::::builder() .model_name("openai/gpt-oss-20b") .api_key("your-api-key") .base_url("http://127.0.0.1:1234/v1") .path("https://full-url.example/v1/chat/completions") .provider_name("Lmstudio") .build()?; ``` **Warning**: When using `DynamicModel`, model capabilities are **not validated at compile time**. This means there's no guarantee the model supports requested features (e.g., tool calls, structured output). For compile-time safety, use the typed methods like `Lmstudio::openai_gpt_oss_20b()`. ## Next Steps * Take a deeper look at text generation features [Generating Text](/docs/concepts/generating-text#generate_text) / [Streaming Text](/docs/concepts/generating-text#stream_text) * Explore [Structured Output](/docs/concepts/structured-output) for reliable agent data. * Learn how to create [Custom Tools](/docs/concepts/tools). * Learn more about [Agents](/docs/concepts/agents). # Lucidquery (/docs/providers/lucidquery) AISDK provides first-class support for Lucidquery with fully typed model APIs. Model capabilities are enforced at compile time using Rust's type system. This prevents model capability mismatches and guarantees the selected model is valid for the task (e.g. tool calling). ## Installation Enable the Lucidquery provider feature: ```bash cargo add aisdk --features lucidquery ``` This installs AISDK with the Lucidquery provider enabled. Once you have enabled the Lucidquery provider, you can use all aisdk features with it. ## Create a Provider Instance To create a provider instance, call `Lucidquery::model_name()`, where **model\_name** is the Lucidquery model you want to use. Model names are exposed as snake-case methods. ```rust use aisdk::providers::Lucidquery; let lucidquery = Lucidquery::lucidnova_rf1_100b(); ``` This initializes the provider with: * Model: `"lucidnova-rf1-100b"` * API key from environment (if set with `LUCIDQUERY_API_KEY`) * Lucidquery's default base URL ([https://lucidquery.com/api/v1](https://lucidquery.com/api/v1)) ## Basic Text Generation Example using [LanguageModelRequest](https://docs.rs/aisdk/latest/aisdk/core/struct.LanguageModelRequest.html) for text generation. ```rust use aisdk::{ core::LanguageModelRequest, providers::Lucidquery, }; #[tokio::main] async fn main() -> Result<(), Box> { let lucidquery = Lucidquery::lucidnova_rf1_100b(); let response = LanguageModelRequest::builder() .model(lucidquery) .prompt("Write a short poem about Rust.") .build() .generate_text() .await?; println!("Response text: {:?}", response.text()); Ok(()) } ``` ## Provider Settings You can customize provider configuration using `Lucidquery::builder()` ### API Key ```rust let lucidquery = Lucidquery::::builder() .api_key("your-api-key") .build()?; ``` If not specified, AISDK uses the `LUCIDQUERY_API_KEY` environment variable. ### Base URL Useful when routing through a proxy, gateway, or self-hosted compatible endpoint. ```rust let lucidquery = Lucidquery::::builder() .base_url("https://lucidquery.com/api/v1") .build()?; ``` ### Path (Full URL Override) Use `.path(...)` to override the full request URL instead of only the base URL. ```rust let lucidquery = Lucidquery::::builder() .path("https://full-url.example/v1/chat/completions") .build()?; ``` ### Provider Name For logging, analytics, and observability. ```rust let lucidquery = Lucidquery::::builder() .provider_name("Lucidquery") .build()?; ``` ### Full Custom Configuration Example ```rust let lucidquery = Lucidquery::::builder() .api_key("your-api-key") .base_url("https://lucidquery.com/api/v1") .path("https://full-url.example/v1/chat/completions") .provider_name("Lucidquery") .build()?; ``` ## Dynamic Model Selection For runtime model selection (e.g., loading models from config files), use `DynamicModel`: ### Using model\_name() Method with Default Settings ```rust use aisdk::providers::Lucidquery; // Specify model as a string at runtime let lucidquery = Lucidquery::model_name("lucidnova-rf1-100b"); ``` ### Using Builder Pattern with Custom Settings ```rust use aisdk::{ core::DynamicModel, providers::Lucidquery, }; let lucidquery = Lucidquery::::builder() .model_name("lucidnova-rf1-100b") .api_key("your-api-key") .base_url("https://lucidquery.com/api/v1") .path("https://full-url.example/v1/chat/completions") .provider_name("Lucidquery") .build()?; ``` **Warning**: When using `DynamicModel`, model capabilities are **not validated at compile time**. This means there's no guarantee the model supports requested features (e.g., tool calls, structured output). For compile-time safety, use the typed methods like `Lucidquery::lucidnova_rf1_100b()`. ## Next Steps * Take a deeper look at text generation features [Generating Text](/docs/concepts/generating-text#generate_text) / [Streaming Text](/docs/concepts/generating-text#stream_text) * Explore [Structured Output](/docs/concepts/structured-output) for reliable agent data. * Learn how to create [Custom Tools](/docs/concepts/tools). * Learn more about [Agents](/docs/concepts/agents). # Mistral (/docs/providers/mistral) AISDK provides first-class support for Mistral with fully typed model APIs. Model capabilities are enforced at compile time using Rust's type system. This prevents model capability mismatches and guarantees the selected model is valid for the task (e.g. tool calling). ## Installation Enable the Mistral provider feature: ```bash cargo add aisdk --features mistral ``` This installs AISDK with the Mistral provider enabled. Once you have enabled the Mistral provider, you can use all aisdk features with it. ## Create a Provider Instance To create a provider instance, call `Mistral::model_name()`, where **model\_name** is the Mistral model you want to use. Model names are exposed as snake-case methods. ```rust use aisdk::providers::Mistral; let mistral = Mistral::codestral_latest(); ``` This initializes the provider with: * Model: `"codestral-latest"` * API key from environment (if set with `MISTRAL_API_KEY`) * Mistral's default base URL ([https://api.mistral.ai/v1/](https://api.mistral.ai/v1/)) ## Basic Text Generation Example using [LanguageModelRequest](https://docs.rs/aisdk/latest/aisdk/core/struct.LanguageModelRequest.html) for text generation. ```rust use aisdk::{ core::LanguageModelRequest, providers::Mistral, }; #[tokio::main] async fn main() -> Result<(), Box> { let mistral = Mistral::codestral_latest(); let response = LanguageModelRequest::builder() .model(mistral) .prompt("Write a short poem about Rust.") .build() .generate_text() .await?; println!("Response text: {:?}", response.text()); Ok(()) } ``` ## Provider Settings You can customize provider configuration using `Mistral::builder()` ### API Key ```rust let mistral = Mistral::::builder() .api_key("your-api-key") .build()?; ``` If not specified, AISDK uses the `MISTRAL_API_KEY` environment variable. ### Base URL Useful when routing through a proxy, gateway, or self-hosted compatible endpoint. ```rust let mistral = Mistral::::builder() .base_url("https://api.mistral.ai/v1/") .build()?; ``` ### Path (Full URL Override) Use `.path(...)` to override the full request URL instead of only the base URL. ```rust let mistral = Mistral::::builder() .path("https://full-url.example/v1/chat/completions") .build()?; ``` ### Provider Name For logging, analytics, and observability. ```rust let mistral = Mistral::::builder() .provider_name("Mistral") .build()?; ``` ### Full Custom Configuration Example ```rust let mistral = Mistral::::builder() .api_key("your-api-key") .base_url("https://api.mistral.ai/v1/") .path("https://full-url.example/v1/chat/completions") .provider_name("Mistral") .build()?; ``` ## Dynamic Model Selection For runtime model selection (e.g., loading models from config files), use `DynamicModel`: ### Using model\_name() Method with Default Settings ```rust use aisdk::providers::Mistral; // Specify model as a string at runtime let mistral = Mistral::model_name("codestral-latest"); ``` ### Using Builder Pattern with Custom Settings ```rust use aisdk::{ core::DynamicModel, providers::Mistral, }; let mistral = Mistral::::builder() .model_name("codestral-latest") .api_key("your-api-key") .base_url("https://api.mistral.ai/v1/") .path("https://full-url.example/v1/chat/completions") .provider_name("Mistral") .build()?; ``` **Warning**: When using `DynamicModel`, model capabilities are **not validated at compile time**. This means there's no guarantee the model supports requested features (e.g., tool calls, structured output). For compile-time safety, use the typed methods like `Mistral::codestral_latest()`. ## Next Steps * Take a deeper look at text generation features [Generating Text](/docs/concepts/generating-text#generate_text) / [Streaming Text](/docs/concepts/generating-text#stream_text) * Explore [Structured Output](/docs/concepts/structured-output) for reliable agent data. * Learn how to create [Custom Tools](/docs/concepts/tools). * Learn more about [Agents](/docs/concepts/agents). # Moark (/docs/providers/moark) AISDK provides first-class support for Moark with fully typed model APIs. Model capabilities are enforced at compile time using Rust's type system. This prevents model capability mismatches and guarantees the selected model is valid for the task (e.g. tool calling). ## Installation Enable the Moark provider feature: ```bash cargo add aisdk --features moark ``` This installs AISDK with the Moark provider enabled. Once you have enabled the Moark provider, you can use all aisdk features with it. ## Create a Provider Instance To create a provider instance, call `Moark::model_name()`, where **model\_name** is the Moark model you want to use. Model names are exposed as snake-case methods. ```rust use aisdk::providers::Moark; let moark = Moark::glm_4_7(); ``` This initializes the provider with: * Model: `"GLM-4.7"` * API key from environment (if set with `MOARK_API_KEY`) * Moark's default base URL ([https://moark.com/v1](https://moark.com/v1)) ## Basic Text Generation Example using [LanguageModelRequest](https://docs.rs/aisdk/latest/aisdk/core/struct.LanguageModelRequest.html) for text generation. ```rust use aisdk::{ core::LanguageModelRequest, providers::Moark, }; #[tokio::main] async fn main() -> Result<(), Box> { let moark = Moark::glm_4_7(); let response = LanguageModelRequest::builder() .model(moark) .prompt("Write a short poem about Rust.") .build() .generate_text() .await?; println!("Response text: {:?}", response.text()); Ok(()) } ``` ## Provider Settings You can customize provider configuration using `Moark::builder()` ### API Key ```rust let moark = Moark::::builder() .api_key("your-api-key") .build()?; ``` If not specified, AISDK uses the `MOARK_API_KEY` environment variable. ### Base URL Useful when routing through a proxy, gateway, or self-hosted compatible endpoint. ```rust let moark = Moark::::builder() .base_url("https://moark.com/v1") .build()?; ``` ### Path (Full URL Override) Use `.path(...)` to override the full request URL instead of only the base URL. ```rust let moark = Moark::::builder() .path("https://full-url.example/v1/chat/completions") .build()?; ``` ### Provider Name For logging, analytics, and observability. ```rust let moark = Moark::::builder() .provider_name("Moark") .build()?; ``` ### Full Custom Configuration Example ```rust let moark = Moark::::builder() .api_key("your-api-key") .base_url("https://moark.com/v1") .path("https://full-url.example/v1/chat/completions") .provider_name("Moark") .build()?; ``` ## Dynamic Model Selection For runtime model selection (e.g., loading models from config files), use `DynamicModel`: ### Using model\_name() Method with Default Settings ```rust use aisdk::providers::Moark; // Specify model as a string at runtime let moark = Moark::model_name("GLM-4.7"); ``` ### Using Builder Pattern with Custom Settings ```rust use aisdk::{ core::DynamicModel, providers::Moark, }; let moark = Moark::::builder() .model_name("GLM-4.7") .api_key("your-api-key") .base_url("https://moark.com/v1") .path("https://full-url.example/v1/chat/completions") .provider_name("Moark") .build()?; ``` **Warning**: When using `DynamicModel`, model capabilities are **not validated at compile time**. This means there's no guarantee the model supports requested features (e.g., tool calls, structured output). For compile-time safety, use the typed methods like `Moark::glm_4_7()`. ## Next Steps * Take a deeper look at text generation features [Generating Text](/docs/concepts/generating-text#generate_text) / [Streaming Text](/docs/concepts/generating-text#stream_text) * Explore [Structured Output](/docs/concepts/structured-output) for reliable agent data. * Learn how to create [Custom Tools](/docs/concepts/tools). * Learn more about [Agents](/docs/concepts/agents). # Modelscope (/docs/providers/modelscope) AISDK provides first-class support for Modelscope with fully typed model APIs. Model capabilities are enforced at compile time using Rust's type system. This prevents model capability mismatches and guarantees the selected model is valid for the task (e.g. tool calling). ## Installation Enable the Modelscope provider feature: ```bash cargo add aisdk --features modelscope ``` This installs AISDK with the Modelscope provider enabled. Once you have enabled the Modelscope provider, you can use all aisdk features with it. ## Create a Provider Instance To create a provider instance, call `Modelscope::model_name()`, where **model\_name** is the Modelscope model you want to use. Model names are exposed as snake-case methods. ```rust use aisdk::providers::Modelscope; let modelscope = Modelscope::qwen_qwen3_235b_a22b_instruct_2507(); ``` This initializes the provider with: * Model: `"Qwen/Qwen3-235B-A22B-Instruct-2507"` * API key from environment (if set with `MODELSCOPE_API_KEY`) * Modelscope's default base URL ([https://api-inference.modelscope.cn/v1](https://api-inference.modelscope.cn/v1)) ## Basic Text Generation Example using [LanguageModelRequest](https://docs.rs/aisdk/latest/aisdk/core/struct.LanguageModelRequest.html) for text generation. ```rust use aisdk::{ core::LanguageModelRequest, providers::Modelscope, }; #[tokio::main] async fn main() -> Result<(), Box> { let modelscope = Modelscope::qwen_qwen3_235b_a22b_instruct_2507(); let response = LanguageModelRequest::builder() .model(modelscope) .prompt("Write a short poem about Rust.") .build() .generate_text() .await?; println!("Response text: {:?}", response.text()); Ok(()) } ``` ## Provider Settings You can customize provider configuration using `Modelscope::builder()` ### API Key ```rust let modelscope = Modelscope::::builder() .api_key("your-api-key") .build()?; ``` If not specified, AISDK uses the `MODELSCOPE_API_KEY` environment variable. ### Base URL Useful when routing through a proxy, gateway, or self-hosted compatible endpoint. ```rust let modelscope = Modelscope::::builder() .base_url("https://api-inference.modelscope.cn/v1") .build()?; ``` ### Path (Full URL Override) Use `.path(...)` to override the full request URL instead of only the base URL. ```rust let modelscope = Modelscope::::builder() .path("https://full-url.example/v1/chat/completions") .build()?; ``` ### Provider Name For logging, analytics, and observability. ```rust let modelscope = Modelscope::::builder() .provider_name("Modelscope") .build()?; ``` ### Full Custom Configuration Example ```rust let modelscope = Modelscope::::builder() .api_key("your-api-key") .base_url("https://api-inference.modelscope.cn/v1") .path("https://full-url.example/v1/chat/completions") .provider_name("Modelscope") .build()?; ``` ## Dynamic Model Selection For runtime model selection (e.g., loading models from config files), use `DynamicModel`: ### Using model\_name() Method with Default Settings ```rust use aisdk::providers::Modelscope; // Specify model as a string at runtime let modelscope = Modelscope::model_name("Qwen/Qwen3-235B-A22B-Instruct-2507"); ``` ### Using Builder Pattern with Custom Settings ```rust use aisdk::{ core::DynamicModel, providers::Modelscope, }; let modelscope = Modelscope::::builder() .model_name("Qwen/Qwen3-235B-A22B-Instruct-2507") .api_key("your-api-key") .base_url("https://api-inference.modelscope.cn/v1") .path("https://full-url.example/v1/chat/completions") .provider_name("Modelscope") .build()?; ``` **Warning**: When using `DynamicModel`, model capabilities are **not validated at compile time**. This means there's no guarantee the model supports requested features (e.g., tool calls, structured output). For compile-time safety, use the typed methods like `Modelscope::qwen_qwen3_235b_a22b_instruct_2507()`. ## Next Steps * Take a deeper look at text generation features [Generating Text](/docs/concepts/generating-text#generate_text) / [Streaming Text](/docs/concepts/generating-text#stream_text) * Explore [Structured Output](/docs/concepts/structured-output) for reliable agent data. * Learn how to create [Custom Tools](/docs/concepts/tools). * Learn more about [Agents](/docs/concepts/agents). # MoonshotaiCn (/docs/providers/moonshotai-cn) AISDK provides first-class support for MoonshotaiCn with fully typed model APIs. Model capabilities are enforced at compile time using Rust's type system. This prevents model capability mismatches and guarantees the selected model is valid for the task (e.g. tool calling). ## Installation Enable the MoonshotaiCn provider feature: ```bash cargo add aisdk --features moonshotai-cn ``` This installs AISDK with the MoonshotaiCn provider enabled. Once you have enabled the MoonshotaiCn provider, you can use all aisdk features with it. ## Create a Provider Instance To create a provider instance, call `MoonshotaiCn::model_name()`, where **model\_name** is the MoonshotaiCn model you want to use. Model names are exposed as snake-case methods. ```rust use aisdk::providers::MoonshotaiCn; let moonshotai-cn = MoonshotaiCn::kimi_k2_0711_preview(); ``` This initializes the provider with: * Model: `"kimi-k2-0711-preview"` * API key from environment (if set with `MOONSHOT_API_KEY`) * MoonshotaiCn's default base URL ([https://api.moonshot.cn/v1](https://api.moonshot.cn/v1)) ## Basic Text Generation Example using [LanguageModelRequest](https://docs.rs/aisdk/latest/aisdk/core/struct.LanguageModelRequest.html) for text generation. ```rust use aisdk::{ core::LanguageModelRequest, providers::MoonshotaiCn, }; #[tokio::main] async fn main() -> Result<(), Box> { let moonshotai-cn = MoonshotaiCn::kimi_k2_0711_preview(); let response = LanguageModelRequest::builder() .model(moonshotai-cn) .prompt("Write a short poem about Rust.") .build() .generate_text() .await?; println!("Response text: {:?}", response.text()); Ok(()) } ``` ## Provider Settings You can customize provider configuration using `MoonshotaiCn::builder()` ### API Key ```rust let moonshotai-cn = MoonshotaiCn::::builder() .api_key("your-api-key") .build()?; ``` If not specified, AISDK uses the `MOONSHOT_API_KEY` environment variable. ### Base URL Useful when routing through a proxy, gateway, or self-hosted compatible endpoint. ```rust let moonshotai-cn = MoonshotaiCn::::builder() .base_url("https://api.moonshot.cn/v1") .build()?; ``` ### Path (Full URL Override) Use `.path(...)` to override the full request URL instead of only the base URL. ```rust let moonshotai-cn = MoonshotaiCn::::builder() .path("https://full-url.example/v1/chat/completions") .build()?; ``` ### Provider Name For logging, analytics, and observability. ```rust let moonshotai-cn = MoonshotaiCn::::builder() .provider_name("MoonshotaiCn") .build()?; ``` ### Full Custom Configuration Example ```rust let moonshotai-cn = MoonshotaiCn::::builder() .api_key("your-api-key") .base_url("https://api.moonshot.cn/v1") .path("https://full-url.example/v1/chat/completions") .provider_name("MoonshotaiCn") .build()?; ``` ## Dynamic Model Selection For runtime model selection (e.g., loading models from config files), use `DynamicModel`: ### Using model\_name() Method with Default Settings ```rust use aisdk::providers::MoonshotaiCn; // Specify model as a string at runtime let moonshotai-cn = MoonshotaiCn::model_name("kimi-k2-0711-preview"); ``` ### Using Builder Pattern with Custom Settings ```rust use aisdk::{ core::DynamicModel, providers::MoonshotaiCn, }; let moonshotai-cn = MoonshotaiCn::::builder() .model_name("kimi-k2-0711-preview") .api_key("your-api-key") .base_url("https://api.moonshot.cn/v1") .path("https://full-url.example/v1/chat/completions") .provider_name("MoonshotaiCn") .build()?; ``` **Warning**: When using `DynamicModel`, model capabilities are **not validated at compile time**. This means there's no guarantee the model supports requested features (e.g., tool calls, structured output). For compile-time safety, use the typed methods like `MoonshotaiCn::kimi_k2_0711_preview()`. ## Next Steps * Take a deeper look at text generation features [Generating Text](/docs/concepts/generating-text#generate_text) / [Streaming Text](/docs/concepts/generating-text#stream_text) * Explore [Structured Output](/docs/concepts/structured-output) for reliable agent data. * Learn how to create [Custom Tools](/docs/concepts/tools). * Learn more about [Agents](/docs/concepts/agents). # Moonshotai (/docs/providers/moonshotai) AISDK provides first-class support for Moonshotai with fully typed model APIs. Model capabilities are enforced at compile time using Rust's type system. This prevents model capability mismatches and guarantees the selected model is valid for the task (e.g. tool calling). ## Installation Enable the Moonshotai provider feature: ```bash cargo add aisdk --features moonshotai ``` This installs AISDK with the Moonshotai provider enabled. Once you have enabled the Moonshotai provider, you can use all aisdk features with it. ## Create a Provider Instance To create a provider instance, call `Moonshotai::model_name()`, where **model\_name** is the Moonshotai model you want to use. Model names are exposed as snake-case methods. ```rust use aisdk::providers::Moonshotai; let moonshotai = Moonshotai::kimi_k2_0711_preview(); ``` This initializes the provider with: * Model: `"kimi-k2-0711-preview"` * API key from environment (if set with `MOONSHOT_API_KEY`) * Moonshotai's default base URL ([https://api.moonshot.ai/v1](https://api.moonshot.ai/v1)) ## Basic Text Generation Example using [LanguageModelRequest](https://docs.rs/aisdk/latest/aisdk/core/struct.LanguageModelRequest.html) for text generation. ```rust use aisdk::{ core::LanguageModelRequest, providers::Moonshotai, }; #[tokio::main] async fn main() -> Result<(), Box> { let moonshotai = Moonshotai::kimi_k2_0711_preview(); let response = LanguageModelRequest::builder() .model(moonshotai) .prompt("Write a short poem about Rust.") .build() .generate_text() .await?; println!("Response text: {:?}", response.text()); Ok(()) } ``` ## Provider Settings You can customize provider configuration using `Moonshotai::builder()` ### API Key ```rust let moonshotai = Moonshotai::::builder() .api_key("your-api-key") .build()?; ``` If not specified, AISDK uses the `MOONSHOT_API_KEY` environment variable. ### Base URL Useful when routing through a proxy, gateway, or self-hosted compatible endpoint. ```rust let moonshotai = Moonshotai::::builder() .base_url("https://api.moonshot.ai/v1") .build()?; ``` ### Path (Full URL Override) Use `.path(...)` to override the full request URL instead of only the base URL. ```rust let moonshotai = Moonshotai::::builder() .path("https://full-url.example/v1/chat/completions") .build()?; ``` ### Provider Name For logging, analytics, and observability. ```rust let moonshotai = Moonshotai::::builder() .provider_name("Moonshotai") .build()?; ``` ### Full Custom Configuration Example ```rust let moonshotai = Moonshotai::::builder() .api_key("your-api-key") .base_url("https://api.moonshot.ai/v1") .path("https://full-url.example/v1/chat/completions") .provider_name("Moonshotai") .build()?; ``` ## Dynamic Model Selection For runtime model selection (e.g., loading models from config files), use `DynamicModel`: ### Using model\_name() Method with Default Settings ```rust use aisdk::providers::Moonshotai; // Specify model as a string at runtime let moonshotai = Moonshotai::model_name("kimi-k2-0711-preview"); ``` ### Using Builder Pattern with Custom Settings ```rust use aisdk::{ core::DynamicModel, providers::Moonshotai, }; let moonshotai = Moonshotai::::builder() .model_name("kimi-k2-0711-preview") .api_key("your-api-key") .base_url("https://api.moonshot.ai/v1") .path("https://full-url.example/v1/chat/completions") .provider_name("Moonshotai") .build()?; ``` **Warning**: When using `DynamicModel`, model capabilities are **not validated at compile time**. This means there's no guarantee the model supports requested features (e.g., tool calls, structured output). For compile-time safety, use the typed methods like `Moonshotai::kimi_k2_0711_preview()`. ## Next Steps * Take a deeper look at text generation features [Generating Text](/docs/concepts/generating-text#generate_text) / [Streaming Text](/docs/concepts/generating-text#stream_text) * Explore [Structured Output](/docs/concepts/structured-output) for reliable agent data. * Learn how to create [Custom Tools](/docs/concepts/tools). * Learn more about [Agents](/docs/concepts/agents). # Morph (/docs/providers/morph) AISDK provides first-class support for Morph with fully typed model APIs. Model capabilities are enforced at compile time using Rust's type system. This prevents model capability mismatches and guarantees the selected model is valid for the task (e.g. tool calling). ## Installation Enable the Morph provider feature: ```bash cargo add aisdk --features morph ``` This installs AISDK with the Morph provider enabled. Once you have enabled the Morph provider, you can use all aisdk features with it. ## Create a Provider Instance To create a provider instance, call `Morph::model_name()`, where **model\_name** is the Morph model you want to use. Model names are exposed as snake-case methods. ```rust use aisdk::providers::Morph; let morph = Morph::auto(); ``` This initializes the provider with: * Model: `"auto"` * API key from environment (if set with `MORPH_API_KEY`) * Morph's default base URL ([https://api.morphllm.com/v1](https://api.morphllm.com/v1)) ## Basic Text Generation Example using [LanguageModelRequest](https://docs.rs/aisdk/latest/aisdk/core/struct.LanguageModelRequest.html) for text generation. ```rust use aisdk::{ core::LanguageModelRequest, providers::Morph, }; #[tokio::main] async fn main() -> Result<(), Box> { let morph = Morph::auto(); let response = LanguageModelRequest::builder() .model(morph) .prompt("Write a short poem about Rust.") .build() .generate_text() .await?; println!("Response text: {:?}", response.text()); Ok(()) } ``` ## Provider Settings You can customize provider configuration using `Morph::builder()` ### API Key ```rust let morph = Morph::::builder() .api_key("your-api-key") .build()?; ``` If not specified, AISDK uses the `MORPH_API_KEY` environment variable. ### Base URL Useful when routing through a proxy, gateway, or self-hosted compatible endpoint. ```rust let morph = Morph::::builder() .base_url("https://api.morphllm.com/v1") .build()?; ``` ### Path (Full URL Override) Use `.path(...)` to override the full request URL instead of only the base URL. ```rust let morph = Morph::::builder() .path("https://full-url.example/v1/chat/completions") .build()?; ``` ### Provider Name For logging, analytics, and observability. ```rust let morph = Morph::::builder() .provider_name("Morph") .build()?; ``` ### Full Custom Configuration Example ```rust let morph = Morph::::builder() .api_key("your-api-key") .base_url("https://api.morphllm.com/v1") .path("https://full-url.example/v1/chat/completions") .provider_name("Morph") .build()?; ``` ## Dynamic Model Selection For runtime model selection (e.g., loading models from config files), use `DynamicModel`: ### Using model\_name() Method with Default Settings ```rust use aisdk::providers::Morph; // Specify model as a string at runtime let morph = Morph::model_name("auto"); ``` ### Using Builder Pattern with Custom Settings ```rust use aisdk::{ core::DynamicModel, providers::Morph, }; let morph = Morph::::builder() .model_name("auto") .api_key("your-api-key") .base_url("https://api.morphllm.com/v1") .path("https://full-url.example/v1/chat/completions") .provider_name("Morph") .build()?; ``` **Warning**: When using `DynamicModel`, model capabilities are **not validated at compile time**. This means there's no guarantee the model supports requested features (e.g., tool calls, structured output). For compile-time safety, use the typed methods like `Morph::auto()`. ## Next Steps * Take a deeper look at text generation features [Generating Text](/docs/concepts/generating-text#generate_text) / [Streaming Text](/docs/concepts/generating-text#stream_text) * Explore [Structured Output](/docs/concepts/structured-output) for reliable agent data. * Learn how to create [Custom Tools](/docs/concepts/tools). * Learn more about [Agents](/docs/concepts/agents). # NanoGpt (/docs/providers/nano-gpt) AISDK provides first-class support for NanoGpt with fully typed model APIs. Model capabilities are enforced at compile time using Rust's type system. This prevents model capability mismatches and guarantees the selected model is valid for the task (e.g. tool calling). ## Installation Enable the NanoGpt provider feature: ```bash cargo add aisdk --features nano-gpt ``` This installs AISDK with the NanoGpt provider enabled. Once you have enabled the NanoGpt provider, you can use all aisdk features with it. ## Create a Provider Instance To create a provider instance, call `NanoGpt::model_name()`, where **model\_name** is the NanoGpt model you want to use. Model names are exposed as snake-case methods. ```rust use aisdk::providers::NanoGpt; let nano-gpt = NanoGpt::deepseek_deepseek_r1(); ``` This initializes the provider with: * Model: `"deepseek/deepseek-r1"` * API key from environment (if set with `NANO_GPT_API_KEY`) * NanoGpt's default base URL ([https://nano-gpt.com/api/v1](https://nano-gpt.com/api/v1)) ## Basic Text Generation Example using [LanguageModelRequest](https://docs.rs/aisdk/latest/aisdk/core/struct.LanguageModelRequest.html) for text generation. ```rust use aisdk::{ core::LanguageModelRequest, providers::NanoGpt, }; #[tokio::main] async fn main() -> Result<(), Box> { let nano-gpt = NanoGpt::deepseek_deepseek_r1(); let response = LanguageModelRequest::builder() .model(nano-gpt) .prompt("Write a short poem about Rust.") .build() .generate_text() .await?; println!("Response text: {:?}", response.text()); Ok(()) } ``` ## Provider Settings You can customize provider configuration using `NanoGpt::builder()` ### API Key ```rust let nano-gpt = NanoGpt::::builder() .api_key("your-api-key") .build()?; ``` If not specified, AISDK uses the `NANO_GPT_API_KEY` environment variable. ### Base URL Useful when routing through a proxy, gateway, or self-hosted compatible endpoint. ```rust let nano-gpt = NanoGpt::::builder() .base_url("https://nano-gpt.com/api/v1") .build()?; ``` ### Path (Full URL Override) Use `.path(...)` to override the full request URL instead of only the base URL. ```rust let nano-gpt = NanoGpt::::builder() .path("https://full-url.example/v1/chat/completions") .build()?; ``` ### Provider Name For logging, analytics, and observability. ```rust let nano-gpt = NanoGpt::::builder() .provider_name("NanoGpt") .build()?; ``` ### Full Custom Configuration Example ```rust let nano-gpt = NanoGpt::::builder() .api_key("your-api-key") .base_url("https://nano-gpt.com/api/v1") .path("https://full-url.example/v1/chat/completions") .provider_name("NanoGpt") .build()?; ``` ## Dynamic Model Selection For runtime model selection (e.g., loading models from config files), use `DynamicModel`: ### Using model\_name() Method with Default Settings ```rust use aisdk::providers::NanoGpt; // Specify model as a string at runtime let nano-gpt = NanoGpt::model_name("deepseek/deepseek-r1"); ``` ### Using Builder Pattern with Custom Settings ```rust use aisdk::{ core::DynamicModel, providers::NanoGpt, }; let nano-gpt = NanoGpt::::builder() .model_name("deepseek/deepseek-r1") .api_key("your-api-key") .base_url("https://nano-gpt.com/api/v1") .path("https://full-url.example/v1/chat/completions") .provider_name("NanoGpt") .build()?; ``` **Warning**: When using `DynamicModel`, model capabilities are **not validated at compile time**. This means there's no guarantee the model supports requested features (e.g., tool calls, structured output). For compile-time safety, use the typed methods like `NanoGpt::deepseek_deepseek_r1()`. ## Next Steps * Take a deeper look at text generation features [Generating Text](/docs/concepts/generating-text#generate_text) / [Streaming Text](/docs/concepts/generating-text#stream_text) * Explore [Structured Output](/docs/concepts/structured-output) for reliable agent data. * Learn how to create [Custom Tools](/docs/concepts/tools). * Learn more about [Agents](/docs/concepts/agents). # Nebius (/docs/providers/nebius) AISDK provides first-class support for Nebius with fully typed model APIs. Model capabilities are enforced at compile time using Rust's type system. This prevents model capability mismatches and guarantees the selected model is valid for the task (e.g. tool calling). ## Installation Enable the Nebius provider feature: ```bash cargo add aisdk --features nebius ``` This installs AISDK with the Nebius provider enabled. Once you have enabled the Nebius provider, you can use all aisdk features with it. ## Create a Provider Instance To create a provider instance, call `Nebius::model_name()`, where **model\_name** is the Nebius model you want to use. Model names are exposed as snake-case methods. ```rust use aisdk::providers::Nebius; let nebius = Nebius::baai_bge_en_icl(); ``` This initializes the provider with: * Model: `"BAAI/bge-en-icl"` * API key from environment (if set with `NEBIUS_API_KEY`) * Nebius's default base URL ([https://api.tokenfactory.nebius.com/v1](https://api.tokenfactory.nebius.com/v1)) ## Basic Text Generation Example using [LanguageModelRequest](https://docs.rs/aisdk/latest/aisdk/core/struct.LanguageModelRequest.html) for text generation. ```rust use aisdk::{ core::LanguageModelRequest, providers::Nebius, }; #[tokio::main] async fn main() -> Result<(), Box> { let nebius = Nebius::baai_bge_en_icl(); let response = LanguageModelRequest::builder() .model(nebius) .prompt("Write a short poem about Rust.") .build() .generate_text() .await?; println!("Response text: {:?}", response.text()); Ok(()) } ``` ## Provider Settings You can customize provider configuration using `Nebius::builder()` ### API Key ```rust let nebius = Nebius::::builder() .api_key("your-api-key") .build()?; ``` If not specified, AISDK uses the `NEBIUS_API_KEY` environment variable. ### Base URL Useful when routing through a proxy, gateway, or self-hosted compatible endpoint. ```rust let nebius = Nebius::::builder() .base_url("https://api.tokenfactory.nebius.com/v1") .build()?; ``` ### Path (Full URL Override) Use `.path(...)` to override the full request URL instead of only the base URL. ```rust let nebius = Nebius::::builder() .path("https://full-url.example/v1/chat/completions") .build()?; ``` ### Provider Name For logging, analytics, and observability. ```rust let nebius = Nebius::::builder() .provider_name("Nebius") .build()?; ``` ### Full Custom Configuration Example ```rust let nebius = Nebius::::builder() .api_key("your-api-key") .base_url("https://api.tokenfactory.nebius.com/v1") .path("https://full-url.example/v1/chat/completions") .provider_name("Nebius") .build()?; ``` ## Dynamic Model Selection For runtime model selection (e.g., loading models from config files), use `DynamicModel`: ### Using model\_name() Method with Default Settings ```rust use aisdk::providers::Nebius; // Specify model as a string at runtime let nebius = Nebius::model_name("BAAI/bge-en-icl"); ``` ### Using Builder Pattern with Custom Settings ```rust use aisdk::{ core::DynamicModel, providers::Nebius, }; let nebius = Nebius::::builder() .model_name("BAAI/bge-en-icl") .api_key("your-api-key") .base_url("https://api.tokenfactory.nebius.com/v1") .path("https://full-url.example/v1/chat/completions") .provider_name("Nebius") .build()?; ``` **Warning**: When using `DynamicModel`, model capabilities are **not validated at compile time**. This means there's no guarantee the model supports requested features (e.g., tool calls, structured output). For compile-time safety, use the typed methods like `Nebius::baai_bge_en_icl()`. ## Next Steps * Take a deeper look at text generation features [Generating Text](/docs/concepts/generating-text#generate_text) / [Streaming Text](/docs/concepts/generating-text#stream_text) * Explore [Structured Output](/docs/concepts/structured-output) for reliable agent data. * Learn how to create [Custom Tools](/docs/concepts/tools). * Learn more about [Agents](/docs/concepts/agents). # Nova (/docs/providers/nova) AISDK provides first-class support for Nova with fully typed model APIs. Model capabilities are enforced at compile time using Rust's type system. This prevents model capability mismatches and guarantees the selected model is valid for the task (e.g. tool calling). ## Installation Enable the Nova provider feature: ```bash cargo add aisdk --features nova ``` This installs AISDK with the Nova provider enabled. Once you have enabled the Nova provider, you can use all aisdk features with it. ## Create a Provider Instance To create a provider instance, call `Nova::model_name()`, where **model\_name** is the Nova model you want to use. Model names are exposed as snake-case methods. ```rust use aisdk::providers::Nova; let nova = Nova::nova_2_lite_v1(); ``` This initializes the provider with: * Model: `"nova-2-lite-v1"` * API key from environment (if set with `NOVA_API_KEY`) * Nova's default base URL ([https://api.nova.amazon.com/v1](https://api.nova.amazon.com/v1)) ## Basic Text Generation Example using [LanguageModelRequest](https://docs.rs/aisdk/latest/aisdk/core/struct.LanguageModelRequest.html) for text generation. ```rust use aisdk::{ core::LanguageModelRequest, providers::Nova, }; #[tokio::main] async fn main() -> Result<(), Box> { let nova = Nova::nova_2_lite_v1(); let response = LanguageModelRequest::builder() .model(nova) .prompt("Write a short poem about Rust.") .build() .generate_text() .await?; println!("Response text: {:?}", response.text()); Ok(()) } ``` ## Provider Settings You can customize provider configuration using `Nova::builder()` ### API Key ```rust let nova = Nova::::builder() .api_key("your-api-key") .build()?; ``` If not specified, AISDK uses the `NOVA_API_KEY` environment variable. ### Base URL Useful when routing through a proxy, gateway, or self-hosted compatible endpoint. ```rust let nova = Nova::::builder() .base_url("https://api.nova.amazon.com/v1") .build()?; ``` ### Path (Full URL Override) Use `.path(...)` to override the full request URL instead of only the base URL. ```rust let nova = Nova::::builder() .path("https://full-url.example/v1/chat/completions") .build()?; ``` ### Provider Name For logging, analytics, and observability. ```rust let nova = Nova::::builder() .provider_name("Nova") .build()?; ``` ### Full Custom Configuration Example ```rust let nova = Nova::::builder() .api_key("your-api-key") .base_url("https://api.nova.amazon.com/v1") .path("https://full-url.example/v1/chat/completions") .provider_name("Nova") .build()?; ``` ## Dynamic Model Selection For runtime model selection (e.g., loading models from config files), use `DynamicModel`: ### Using model\_name() Method with Default Settings ```rust use aisdk::providers::Nova; // Specify model as a string at runtime let nova = Nova::model_name("nova-2-lite-v1"); ``` ### Using Builder Pattern with Custom Settings ```rust use aisdk::{ core::DynamicModel, providers::Nova, }; let nova = Nova::::builder() .model_name("nova-2-lite-v1") .api_key("your-api-key") .base_url("https://api.nova.amazon.com/v1") .path("https://full-url.example/v1/chat/completions") .provider_name("Nova") .build()?; ``` **Warning**: When using `DynamicModel`, model capabilities are **not validated at compile time**. This means there's no guarantee the model supports requested features (e.g., tool calls, structured output). For compile-time safety, use the typed methods like `Nova::nova_2_lite_v1()`. ## Next Steps * Take a deeper look at text generation features [Generating Text](/docs/concepts/generating-text#generate_text) / [Streaming Text](/docs/concepts/generating-text#stream_text) * Explore [Structured Output](/docs/concepts/structured-output) for reliable agent data. * Learn how to create [Custom Tools](/docs/concepts/tools). * Learn more about [Agents](/docs/concepts/agents). # NovitaAi (/docs/providers/novita-ai) AISDK provides first-class support for NovitaAi with fully typed model APIs. Model capabilities are enforced at compile time using Rust's type system. This prevents model capability mismatches and guarantees the selected model is valid for the task (e.g. tool calling). ## Installation Enable the NovitaAi provider feature: ```bash cargo add aisdk --features novita-ai ``` This installs AISDK with the NovitaAi provider enabled. Once you have enabled the NovitaAi provider, you can use all aisdk features with it. ## Create a Provider Instance To create a provider instance, call `NovitaAi::model_name()`, where **model\_name** is the NovitaAi model you want to use. Model names are exposed as snake-case methods. ```rust use aisdk::providers::NovitaAi; let novita-ai = NovitaAi::baichuan_baichuan_m2_32b(); ``` This initializes the provider with: * Model: `"baichuan/baichuan-m2-32b"` * API key from environment (if set with `NOVITA_API_KEY`) * NovitaAi's default base URL ([https://api.novita.ai/openai](https://api.novita.ai/openai)) ## Basic Text Generation Example using [LanguageModelRequest](https://docs.rs/aisdk/latest/aisdk/core/struct.LanguageModelRequest.html) for text generation. ```rust use aisdk::{ core::LanguageModelRequest, providers::NovitaAi, }; #[tokio::main] async fn main() -> Result<(), Box> { let novita-ai = NovitaAi::baichuan_baichuan_m2_32b(); let response = LanguageModelRequest::builder() .model(novita-ai) .prompt("Write a short poem about Rust.") .build() .generate_text() .await?; println!("Response text: {:?}", response.text()); Ok(()) } ``` ## Provider Settings You can customize provider configuration using `NovitaAi::builder()` ### API Key ```rust let novita-ai = NovitaAi::::builder() .api_key("your-api-key") .build()?; ``` If not specified, AISDK uses the `NOVITA_API_KEY` environment variable. ### Base URL Useful when routing through a proxy, gateway, or self-hosted compatible endpoint. ```rust let novita-ai = NovitaAi::::builder() .base_url("https://api.novita.ai/openai") .build()?; ``` ### Path (Full URL Override) Use `.path(...)` to override the full request URL instead of only the base URL. ```rust let novita-ai = NovitaAi::::builder() .path("https://full-url.example/v1/chat/completions") .build()?; ``` ### Provider Name For logging, analytics, and observability. ```rust let novita-ai = NovitaAi::::builder() .provider_name("NovitaAi") .build()?; ``` ### Full Custom Configuration Example ```rust let novita-ai = NovitaAi::::builder() .api_key("your-api-key") .base_url("https://api.novita.ai/openai") .path("https://full-url.example/v1/chat/completions") .provider_name("NovitaAi") .build()?; ``` ## Dynamic Model Selection For runtime model selection (e.g., loading models from config files), use `DynamicModel`: ### Using model\_name() Method with Default Settings ```rust use aisdk::providers::NovitaAi; // Specify model as a string at runtime let novita-ai = NovitaAi::model_name("baichuan/baichuan-m2-32b"); ``` ### Using Builder Pattern with Custom Settings ```rust use aisdk::{ core::DynamicModel, providers::NovitaAi, }; let novita-ai = NovitaAi::::builder() .model_name("baichuan/baichuan-m2-32b") .api_key("your-api-key") .base_url("https://api.novita.ai/openai") .path("https://full-url.example/v1/chat/completions") .provider_name("NovitaAi") .build()?; ``` **Warning**: When using `DynamicModel`, model capabilities are **not validated at compile time**. This means there's no guarantee the model supports requested features (e.g., tool calls, structured output). For compile-time safety, use the typed methods like `NovitaAi::baichuan_baichuan_m2_32b()`. ## Next Steps * Take a deeper look at text generation features [Generating Text](/docs/concepts/generating-text#generate_text) / [Streaming Text](/docs/concepts/generating-text#stream_text) * Explore [Structured Output](/docs/concepts/structured-output) for reliable agent data. * Learn how to create [Custom Tools](/docs/concepts/tools). * Learn more about [Agents](/docs/concepts/agents). # Nvidia (/docs/providers/nvidia) AISDK provides first-class support for Nvidia with fully typed model APIs. Model capabilities are enforced at compile time using Rust's type system. This prevents model capability mismatches and guarantees the selected model is valid for the task (e.g. tool calling). ## Installation Enable the Nvidia provider feature: ```bash cargo add aisdk --features nvidia ``` This installs AISDK with the Nvidia provider enabled. Once you have enabled the Nvidia provider, you can use all aisdk features with it. ## Create a Provider Instance To create a provider instance, call `Nvidia::model_name()`, where **model\_name** is the Nvidia model you want to use. Model names are exposed as snake-case methods. ```rust use aisdk::providers::Nvidia; let nvidia = Nvidia::black_forest_labs_flux_1_dev(); ``` This initializes the provider with: * Model: `"black-forest-labs/flux.1-dev"` * API key from environment (if set with `NVIDIA_API_KEY`) * Nvidia's default base URL ([https://integrate.api.nvidia.com/v1](https://integrate.api.nvidia.com/v1)) ## Basic Text Generation Example using [LanguageModelRequest](https://docs.rs/aisdk/latest/aisdk/core/struct.LanguageModelRequest.html) for text generation. ```rust use aisdk::{ core::LanguageModelRequest, providers::Nvidia, }; #[tokio::main] async fn main() -> Result<(), Box> { let nvidia = Nvidia::black_forest_labs_flux_1_dev(); let response = LanguageModelRequest::builder() .model(nvidia) .prompt("Write a short poem about Rust.") .build() .generate_text() .await?; println!("Response text: {:?}", response.text()); Ok(()) } ``` ## Provider Settings You can customize provider configuration using `Nvidia::builder()` ### API Key ```rust let nvidia = Nvidia::::builder() .api_key("your-api-key") .build()?; ``` If not specified, AISDK uses the `NVIDIA_API_KEY` environment variable. ### Base URL Useful when routing through a proxy, gateway, or self-hosted compatible endpoint. ```rust let nvidia = Nvidia::::builder() .base_url("https://integrate.api.nvidia.com/v1") .build()?; ``` ### Path (Full URL Override) Use `.path(...)` to override the full request URL instead of only the base URL. ```rust let nvidia = Nvidia::::builder() .path("https://full-url.example/v1/chat/completions") .build()?; ``` ### Provider Name For logging, analytics, and observability. ```rust let nvidia = Nvidia::::builder() .provider_name("Nvidia") .build()?; ``` ### Full Custom Configuration Example ```rust let nvidia = Nvidia::::builder() .api_key("your-api-key") .base_url("https://integrate.api.nvidia.com/v1") .path("https://full-url.example/v1/chat/completions") .provider_name("Nvidia") .build()?; ``` ## Dynamic Model Selection For runtime model selection (e.g., loading models from config files), use `DynamicModel`: ### Using model\_name() Method with Default Settings ```rust use aisdk::providers::Nvidia; // Specify model as a string at runtime let nvidia = Nvidia::model_name("black-forest-labs/flux.1-dev"); ``` ### Using Builder Pattern with Custom Settings ```rust use aisdk::{ core::DynamicModel, providers::Nvidia, }; let nvidia = Nvidia::::builder() .model_name("black-forest-labs/flux.1-dev") .api_key("your-api-key") .base_url("https://integrate.api.nvidia.com/v1") .path("https://full-url.example/v1/chat/completions") .provider_name("Nvidia") .build()?; ``` **Warning**: When using `DynamicModel`, model capabilities are **not validated at compile time**. This means there's no guarantee the model supports requested features (e.g., tool calls, structured output). For compile-time safety, use the typed methods like `Nvidia::black_forest_labs_flux_1_dev()`. ## Next Steps * Take a deeper look at text generation features [Generating Text](/docs/concepts/generating-text#generate_text) / [Streaming Text](/docs/concepts/generating-text#stream_text) * Explore [Structured Output](/docs/concepts/structured-output) for reliable agent data. * Learn how to create [Custom Tools](/docs/concepts/tools). * Learn more about [Agents](/docs/concepts/agents). # OllamaCloud (/docs/providers/ollama-cloud) AISDK provides first-class support for OllamaCloud with fully typed model APIs. Model capabilities are enforced at compile time using Rust's type system. This prevents model capability mismatches and guarantees the selected model is valid for the task (e.g. tool calling). ## Installation Enable the OllamaCloud provider feature: ```bash cargo add aisdk --features ollama-cloud ``` This installs AISDK with the OllamaCloud provider enabled. Once you have enabled the OllamaCloud provider, you can use all aisdk features with it. ## Create a Provider Instance To create a provider instance, call `OllamaCloud::model_name()`, where **model\_name** is the OllamaCloud model you want to use. Model names are exposed as snake-case methods. ```rust use aisdk::providers::OllamaCloud; let ollama-cloud = OllamaCloud::cogito_2_1_671b(); ``` This initializes the provider with: * Model: `"cogito-2.1:671b"` * API key from environment (if set with `OLLAMA_API_KEY`) * OllamaCloud's default base URL ([https://ollama.com/v1](https://ollama.com/v1)) ## Basic Text Generation Example using [LanguageModelRequest](https://docs.rs/aisdk/latest/aisdk/core/struct.LanguageModelRequest.html) for text generation. ```rust use aisdk::{ core::LanguageModelRequest, providers::OllamaCloud, }; #[tokio::main] async fn main() -> Result<(), Box> { let ollama-cloud = OllamaCloud::cogito_2_1_671b(); let response = LanguageModelRequest::builder() .model(ollama-cloud) .prompt("Write a short poem about Rust.") .build() .generate_text() .await?; println!("Response text: {:?}", response.text()); Ok(()) } ``` ## Provider Settings You can customize provider configuration using `OllamaCloud::builder()` ### API Key ```rust let ollama-cloud = OllamaCloud::::builder() .api_key("your-api-key") .build()?; ``` If not specified, AISDK uses the `OLLAMA_API_KEY` environment variable. ### Base URL Useful when routing through a proxy, gateway, or self-hosted compatible endpoint. ```rust let ollama-cloud = OllamaCloud::::builder() .base_url("https://ollama.com/v1") .build()?; ``` ### Path (Full URL Override) Use `.path(...)` to override the full request URL instead of only the base URL. ```rust let ollama-cloud = OllamaCloud::::builder() .path("https://full-url.example/v1/chat/completions") .build()?; ``` ### Provider Name For logging, analytics, and observability. ```rust let ollama-cloud = OllamaCloud::::builder() .provider_name("OllamaCloud") .build()?; ``` ### Full Custom Configuration Example ```rust let ollama-cloud = OllamaCloud::::builder() .api_key("your-api-key") .base_url("https://ollama.com/v1") .path("https://full-url.example/v1/chat/completions") .provider_name("OllamaCloud") .build()?; ``` ## Dynamic Model Selection For runtime model selection (e.g., loading models from config files), use `DynamicModel`: ### Using model\_name() Method with Default Settings ```rust use aisdk::providers::OllamaCloud; // Specify model as a string at runtime let ollama-cloud = OllamaCloud::model_name("cogito-2.1:671b"); ``` ### Using Builder Pattern with Custom Settings ```rust use aisdk::{ core::DynamicModel, providers::OllamaCloud, }; let ollama-cloud = OllamaCloud::::builder() .model_name("cogito-2.1:671b") .api_key("your-api-key") .base_url("https://ollama.com/v1") .path("https://full-url.example/v1/chat/completions") .provider_name("OllamaCloud") .build()?; ``` **Warning**: When using `DynamicModel`, model capabilities are **not validated at compile time**. This means there's no guarantee the model supports requested features (e.g., tool calls, structured output). For compile-time safety, use the typed methods like `OllamaCloud::cogito_2_1_671b()`. ## Next Steps * Take a deeper look at text generation features [Generating Text](/docs/concepts/generating-text#generate_text) / [Streaming Text](/docs/concepts/generating-text#stream_text) * Explore [Structured Output](/docs/concepts/structured-output) for reliable agent data. * Learn how to create [Custom Tools](/docs/concepts/tools). * Learn more about [Agents](/docs/concepts/agents). # OpenAI (/docs/providers/openai) AISDK provides first-class support for OpenAI with fully typed model APIs. Model capabilities are enforced at compile time using Rust's type system. This prevents model capability mismatches and guarantees the selected model is valid for the task (e.g. tool calling). ## Installation Enable the OpenAI provider feature: ```bash cargo add aisdk --features openai ``` This installs AISDK with the OpenAI provider enabled. Once you have enabled the OpenAI provider, you can use all aisdk features with it. ## Create a Provider Instance To create a provider instance, call `OpenAI::model_name()`, where **model\_name** is the OpenAI model you want to use. Model names are exposed as snake-case methods. ```rust use aisdk::providers::OpenAI; let openai = OpenAI::codex_mini_latest(); ``` This initializes the provider with: * Model: `"codex-mini-latest"` * API key from environment (if set with `OPENAI_API_KEY`) * OpenAI's default base URL ([https://api.openai.com](https://api.openai.com)) ## Basic Text Generation Example using [LanguageModelRequest](https://docs.rs/aisdk/latest/aisdk/core/struct.LanguageModelRequest.html) for text generation. ```rust use aisdk::{ core::LanguageModelRequest, providers::OpenAI, }; #[tokio::main] async fn main() -> Result<(), Box> { let openai = OpenAI::codex_mini_latest(); let response = LanguageModelRequest::builder() .model(openai) .prompt("Write a short poem about Rust.") .build() .generate_text() .await?; println!("Response text: {:?}", response.text()); Ok(()) } ``` ## Provider Settings You can customize provider configuration using `OpenAI::builder()` ### API Key ```rust let openai = OpenAI::::builder() .api_key("your-api-key") .build()?; ``` If not specified, AISDK uses the `OPENAI_API_KEY` environment variable. ### Base URL Useful when routing through a proxy, gateway, or self-hosted compatible endpoint. ```rust let openai = OpenAI::::builder() .base_url("https://api.openai.com") .build()?; ``` ### Path (Full URL Override) Use `.path(...)` to override the full request URL instead of only the base URL. ```rust let openai = OpenAI::::builder() .path("https://full-url.example/v1/chat/completions") .build()?; ``` ### Provider Name For logging, analytics, and observability. ```rust let openai = OpenAI::::builder() .provider_name("OpenAI") .build()?; ``` ### Full Custom Configuration Example ```rust let openai = OpenAI::::builder() .api_key("your-api-key") .base_url("https://api.openai.com") .path("https://full-url.example/v1/chat/completions") .provider_name("OpenAI") .build()?; ``` ## Dynamic Model Selection For runtime model selection (e.g., loading models from config files), use `DynamicModel`: ### Using model\_name() Method with Default Settings ```rust use aisdk::providers::OpenAI; // Specify model as a string at runtime let openai = OpenAI::model_name("codex-mini-latest"); ``` ### Using Builder Pattern with Custom Settings ```rust use aisdk::{ core::DynamicModel, providers::OpenAI, }; let openai = OpenAI::::builder() .model_name("codex-mini-latest") .api_key("your-api-key") .base_url("https://api.openai.com") .path("https://full-url.example/v1/chat/completions") .provider_name("OpenAI") .build()?; ``` **Warning**: When using `DynamicModel`, model capabilities are **not validated at compile time**. This means there's no guarantee the model supports requested features (e.g., tool calls, structured output). For compile-time safety, use the typed methods like `OpenAI::codex_mini_latest()`. ## Next Steps * Take a deeper look at text generation features [Generating Text](/docs/concepts/generating-text#generate_text) / [Streaming Text](/docs/concepts/generating-text#stream_text) * Explore [Structured Output](/docs/concepts/structured-output) for reliable agent data. * Learn how to create [Custom Tools](/docs/concepts/tools). * Learn more about [Agents](/docs/concepts/agents). # OpenAICompatible (/docs/providers/openaicompatible) `OpenAICompatible` is a generic provider for services that implement the OpenAI Chat Completions format. Use it when you want to connect to an OpenAI-compatible endpoint that does not have a dedicated AISDK provider. The target provider should be compatible with the [OpenAI Chat Completions API](https://developers.openai.com/api/reference/resources/chat/). Unlike typed providers (for example `OpenAI::gpt_5()`), `OpenAICompatible` does not expose model methods. Models are selected dynamically with strings. ## Installation Enable the OpenAICompatible feature: ```bash cargo add aisdk --features openaicompatible ``` ## Create a Provider Instance ### Quick Dynamic Instance ```rust use aisdk::providers::OpenAICompatible; let provider = OpenAICompatible::model_name("gpt-4o"); ``` This uses default settings: * Model: `"gpt-4o"` (dynamic string) * API key from `OPENAI_API_KEY` * Base URL: `https://api.openai.com/v1` * Default path behavior for chat completions ### Configure for a Compatible Endpoint ```rust use aisdk::{core::DynamicModel, providers::OpenAICompatible}; let provider = OpenAICompatible::::builder() .model_name("glm-4.5") .base_url("https://api.z.ai/api/coding/paas/v4") .api_key("your-api-key") .provider_name("z-ai") .build()?; ``` ## Basic Text Generation ```rust use aisdk::{ core::{DynamicModel, LanguageModelRequest}, providers::OpenAICompatible, }; #[tokio::main] async fn main() -> Result<(), Box> { let provider = OpenAICompatible::::builder() .model_name("gpt-4o") .base_url("https://api.openai.com/v1") .api_key("your-api-key") .build()?; let response = LanguageModelRequest::builder() .model(provider) .prompt("Write a short poem about Rust.") .build() .generate_text() .await?; println!("Response text: {:?}", response.text()); Ok(()) } ``` ## Provider Settings You can customize provider configuration using `OpenAICompatible::::builder()`. ### API Key ```rust let provider = OpenAICompatible::::builder() .model_name("gpt-4o") .api_key("your-api-key") .build()?; ``` If not specified, AISDK uses `OPENAI_API_KEY`. ### Base URL Use `base_url(...)` for provider-level routing, proxying, or hosted compatible services. ```rust let provider = OpenAICompatible::::builder() .model_name("gpt-4o") .base_url("https://api.openai.com/v1") .build()?; ``` ### Path (Full URL Override) Use `.path(...)` when you need to override the full request URL. ```rust let provider = OpenAICompatible::::builder() .model_name("gpt-4o") .path("https://full-url.example/v1/chat/completions") .build()?; ``` ### Provider Name For logging, analytics, and observability. ```rust let provider = OpenAICompatible::::builder() .model_name("gpt-4o") .provider_name("custom-openai-compatible") .build()?; ``` ### Full Custom Configuration Example ```rust let provider = OpenAICompatible::::builder() .model_name("gpt-4o") .api_key("your-api-key") .base_url("https://api.openai.com/v1") .path("https://full-url.example/v1/chat/completions") .provider_name("custom-openai-compatible") .build()?; ``` ## Model Selection `OpenAICompatible` is designed for runtime model selection: * `OpenAICompatible::model_name("...")` * `OpenAICompatible::::builder().model_name("...")` It does not provide typed static model methods. **Warning**: `OpenAICompatible` uses dynamic model strings, so model capabilities are not validated at compile time. Validate model support (tools, structured output, reasoning, etc.) at runtime for your target endpoint. ## Next Steps * Take a deeper look at text generation features [Generating Text](/docs/concepts/generating-text#generate_text) / [Streaming Text](/docs/concepts/generating-text#stream_text) * Explore [Structured Output](/docs/concepts/structured-output) for reliable agent data. * Learn how to create [Custom Tools](/docs/concepts/tools). * Learn more about [Agents](/docs/concepts/agents). # Opencode (/docs/providers/opencode) AISDK provides first-class support for Opencode with fully typed model APIs. Model capabilities are enforced at compile time using Rust's type system. This prevents model capability mismatches and guarantees the selected model is valid for the task (e.g. tool calling). ## Installation Enable the Opencode provider feature: ```bash cargo add aisdk --features opencode ``` This installs AISDK with the Opencode provider enabled. Once you have enabled the Opencode provider, you can use all aisdk features with it. ## Create a Provider Instance To create a provider instance, call `Opencode::model_name()`, where **model\_name** is the Opencode model you want to use. Model names are exposed as snake-case methods. ```rust use aisdk::providers::Opencode; let opencode = Opencode::big_pickle(); ``` This initializes the provider with: * Model: `"big-pickle"` * API key from environment (if set with `OPENCODE_API_KEY`) * Opencode's default base URL ([https://opencode.ai/zen/v1](https://opencode.ai/zen/v1)) ## Basic Text Generation Example using [LanguageModelRequest](https://docs.rs/aisdk/latest/aisdk/core/struct.LanguageModelRequest.html) for text generation. ```rust use aisdk::{ core::LanguageModelRequest, providers::Opencode, }; #[tokio::main] async fn main() -> Result<(), Box> { let opencode = Opencode::big_pickle(); let response = LanguageModelRequest::builder() .model(opencode) .prompt("Write a short poem about Rust.") .build() .generate_text() .await?; println!("Response text: {:?}", response.text()); Ok(()) } ``` ## Provider Settings You can customize provider configuration using `Opencode::builder()` ### API Key ```rust let opencode = Opencode::::builder() .api_key("your-api-key") .build()?; ``` If not specified, AISDK uses the `OPENCODE_API_KEY` environment variable. ### Base URL Useful when routing through a proxy, gateway, or self-hosted compatible endpoint. ```rust let opencode = Opencode::::builder() .base_url("https://opencode.ai/zen/v1") .build()?; ``` ### Path (Full URL Override) Use `.path(...)` to override the full request URL instead of only the base URL. ```rust let opencode = Opencode::::builder() .path("https://full-url.example/v1/chat/completions") .build()?; ``` ### Provider Name For logging, analytics, and observability. ```rust let opencode = Opencode::::builder() .provider_name("Opencode") .build()?; ``` ### Full Custom Configuration Example ```rust let opencode = Opencode::::builder() .api_key("your-api-key") .base_url("https://opencode.ai/zen/v1") .path("https://full-url.example/v1/chat/completions") .provider_name("Opencode") .build()?; ``` ## Dynamic Model Selection For runtime model selection (e.g., loading models from config files), use `DynamicModel`: ### Using model\_name() Method with Default Settings ```rust use aisdk::providers::Opencode; // Specify model as a string at runtime let opencode = Opencode::model_name("big-pickle"); ``` ### Using Builder Pattern with Custom Settings ```rust use aisdk::{ core::DynamicModel, providers::Opencode, }; let opencode = Opencode::::builder() .model_name("big-pickle") .api_key("your-api-key") .base_url("https://opencode.ai/zen/v1") .path("https://full-url.example/v1/chat/completions") .provider_name("Opencode") .build()?; ``` **Warning**: When using `DynamicModel`, model capabilities are **not validated at compile time**. This means there's no guarantee the model supports requested features (e.g., tool calls, structured output). For compile-time safety, use the typed methods like `Opencode::big_pickle()`. ## Next Steps * Take a deeper look at text generation features [Generating Text](/docs/concepts/generating-text#generate_text) / [Streaming Text](/docs/concepts/generating-text#stream_text) * Explore [Structured Output](/docs/concepts/structured-output) for reliable agent data. * Learn how to create [Custom Tools](/docs/concepts/tools). * Learn more about [Agents](/docs/concepts/agents). # Openrouter (/docs/providers/openrouter) AISDK provides first-class support for Openrouter with fully typed model APIs. Model capabilities are enforced at compile time using Rust's type system. This prevents model capability mismatches and guarantees the selected model is valid for the task (e.g. tool calling). ## Installation Enable the Openrouter provider feature: ```bash cargo add aisdk --features openrouter ``` This installs AISDK with the Openrouter provider enabled. Once you have enabled the Openrouter provider, you can use all aisdk features with it. ## Create a Provider Instance To create a provider instance, call `Openrouter::model_name()`, where **model\_name** is the Openrouter model you want to use. Model names are exposed as snake-case methods. ```rust use aisdk::providers::Openrouter; let openrouter = Openrouter::allenai_molmo_2_8b_free(); ``` This initializes the provider with: * Model: `"allenai/molmo-2-8b:free"` * API key from environment (if set with `OPENROUTER_API_KEY`) * Openrouter's default base URL ([https://openrouter.ai/api/v1](https://openrouter.ai/api/v1)) ## Basic Text Generation Example using [LanguageModelRequest](https://docs.rs/aisdk/latest/aisdk/core/struct.LanguageModelRequest.html) for text generation. ```rust use aisdk::{ core::LanguageModelRequest, providers::Openrouter, }; #[tokio::main] async fn main() -> Result<(), Box> { let openrouter = Openrouter::allenai_molmo_2_8b_free(); let response = LanguageModelRequest::builder() .model(openrouter) .prompt("Write a short poem about Rust.") .build() .generate_text() .await?; println!("Response text: {:?}", response.text()); Ok(()) } ``` ## Provider Settings You can customize provider configuration using `Openrouter::builder()` ### API Key ```rust let openrouter = Openrouter::::builder() .api_key("your-api-key") .build()?; ``` If not specified, AISDK uses the `OPENROUTER_API_KEY` environment variable. ### Base URL Useful when routing through a proxy, gateway, or self-hosted compatible endpoint. ```rust let openrouter = Openrouter::::builder() .base_url("https://openrouter.ai/api/v1") .build()?; ``` ### Path (Full URL Override) Use `.path(...)` to override the full request URL instead of only the base URL. ```rust let openrouter = Openrouter::::builder() .path("https://full-url.example/v1/chat/completions") .build()?; ``` ### Provider Name For logging, analytics, and observability. ```rust let openrouter = Openrouter::::builder() .provider_name("Openrouter") .build()?; ``` ### Full Custom Configuration Example ```rust let openrouter = Openrouter::::builder() .api_key("your-api-key") .base_url("https://openrouter.ai/api/v1") .path("https://full-url.example/v1/chat/completions") .provider_name("Openrouter") .build()?; ``` ## Dynamic Model Selection For runtime model selection (e.g., loading models from config files), use `DynamicModel`: ### Using model\_name() Method with Default Settings ```rust use aisdk::providers::Openrouter; // Specify model as a string at runtime let openrouter = Openrouter::model_name("allenai/molmo-2-8b:free"); ``` ### Using Builder Pattern with Custom Settings ```rust use aisdk::{ core::DynamicModel, providers::Openrouter, }; let openrouter = Openrouter::::builder() .model_name("allenai/molmo-2-8b:free") .api_key("your-api-key") .base_url("https://openrouter.ai/api/v1") .path("https://full-url.example/v1/chat/completions") .provider_name("Openrouter") .build()?; ``` **Warning**: When using `DynamicModel`, model capabilities are **not validated at compile time**. This means there's no guarantee the model supports requested features (e.g., tool calls, structured output). For compile-time safety, use the typed methods like `Openrouter::allenai_molmo_2_8b_free()`. ## Next Steps * Take a deeper look at text generation features [Generating Text](/docs/concepts/generating-text#generate_text) / [Streaming Text](/docs/concepts/generating-text#stream_text) * Explore [Structured Output](/docs/concepts/structured-output) for reliable agent data. * Learn how to create [Custom Tools](/docs/concepts/tools). * Learn more about [Agents](/docs/concepts/agents). # Ovhcloud (/docs/providers/ovhcloud) AISDK provides first-class support for Ovhcloud with fully typed model APIs. Model capabilities are enforced at compile time using Rust's type system. This prevents model capability mismatches and guarantees the selected model is valid for the task (e.g. tool calling). ## Installation Enable the Ovhcloud provider feature: ```bash cargo add aisdk --features ovhcloud ``` This installs AISDK with the Ovhcloud provider enabled. Once you have enabled the Ovhcloud provider, you can use all aisdk features with it. ## Create a Provider Instance To create a provider instance, call `Ovhcloud::model_name()`, where **model\_name** is the Ovhcloud model you want to use. Model names are exposed as snake-case methods. ```rust use aisdk::providers::Ovhcloud; let ovhcloud = Ovhcloud::deepseek_r1_distill_llama_70b(); ``` This initializes the provider with: * Model: `"deepseek-r1-distill-llama-70b"` * API key from environment (if set with `OVHCLOUD_API_KEY`) * Ovhcloud's default base URL ([https://oai.endpoints.kepler.ai.cloud.ovh.net/v1](https://oai.endpoints.kepler.ai.cloud.ovh.net/v1)) ## Basic Text Generation Example using [LanguageModelRequest](https://docs.rs/aisdk/latest/aisdk/core/struct.LanguageModelRequest.html) for text generation. ```rust use aisdk::{ core::LanguageModelRequest, providers::Ovhcloud, }; #[tokio::main] async fn main() -> Result<(), Box> { let ovhcloud = Ovhcloud::deepseek_r1_distill_llama_70b(); let response = LanguageModelRequest::builder() .model(ovhcloud) .prompt("Write a short poem about Rust.") .build() .generate_text() .await?; println!("Response text: {:?}", response.text()); Ok(()) } ``` ## Provider Settings You can customize provider configuration using `Ovhcloud::builder()` ### API Key ```rust let ovhcloud = Ovhcloud::::builder() .api_key("your-api-key") .build()?; ``` If not specified, AISDK uses the `OVHCLOUD_API_KEY` environment variable. ### Base URL Useful when routing through a proxy, gateway, or self-hosted compatible endpoint. ```rust let ovhcloud = Ovhcloud::::builder() .base_url("https://oai.endpoints.kepler.ai.cloud.ovh.net/v1") .build()?; ``` ### Path (Full URL Override) Use `.path(...)` to override the full request URL instead of only the base URL. ```rust let ovhcloud = Ovhcloud::::builder() .path("https://full-url.example/v1/chat/completions") .build()?; ``` ### Provider Name For logging, analytics, and observability. ```rust let ovhcloud = Ovhcloud::::builder() .provider_name("Ovhcloud") .build()?; ``` ### Full Custom Configuration Example ```rust let ovhcloud = Ovhcloud::::builder() .api_key("your-api-key") .base_url("https://oai.endpoints.kepler.ai.cloud.ovh.net/v1") .path("https://full-url.example/v1/chat/completions") .provider_name("Ovhcloud") .build()?; ``` ## Dynamic Model Selection For runtime model selection (e.g., loading models from config files), use `DynamicModel`: ### Using model\_name() Method with Default Settings ```rust use aisdk::providers::Ovhcloud; // Specify model as a string at runtime let ovhcloud = Ovhcloud::model_name("deepseek-r1-distill-llama-70b"); ``` ### Using Builder Pattern with Custom Settings ```rust use aisdk::{ core::DynamicModel, providers::Ovhcloud, }; let ovhcloud = Ovhcloud::::builder() .model_name("deepseek-r1-distill-llama-70b") .api_key("your-api-key") .base_url("https://oai.endpoints.kepler.ai.cloud.ovh.net/v1") .path("https://full-url.example/v1/chat/completions") .provider_name("Ovhcloud") .build()?; ``` **Warning**: When using `DynamicModel`, model capabilities are **not validated at compile time**. This means there's no guarantee the model supports requested features (e.g., tool calls, structured output). For compile-time safety, use the typed methods like `Ovhcloud::deepseek_r1_distill_llama_70b()`. ## Next Steps * Take a deeper look at text generation features [Generating Text](/docs/concepts/generating-text#generate_text) / [Streaming Text](/docs/concepts/generating-text#stream_text) * Explore [Structured Output](/docs/concepts/structured-output) for reliable agent data. * Learn how to create [Custom Tools](/docs/concepts/tools). * Learn more about [Agents](/docs/concepts/agents). # Poe (/docs/providers/poe) AISDK provides first-class support for Poe with fully typed model APIs. Model capabilities are enforced at compile time using Rust's type system. This prevents model capability mismatches and guarantees the selected model is valid for the task (e.g. tool calling). ## Installation Enable the Poe provider feature: ```bash cargo add aisdk --features poe ``` This installs AISDK with the Poe provider enabled. Once you have enabled the Poe provider, you can use all aisdk features with it. ## Create a Provider Instance To create a provider instance, call `Poe::model_name()`, where **model\_name** is the Poe model you want to use. Model names are exposed as snake-case methods. ```rust use aisdk::providers::Poe; let poe = Poe::anthropic_claude_haiku_3(); ``` This initializes the provider with: * Model: `"anthropic/claude-haiku-3"` * API key from environment (if set with `POE_API_KEY`) * Poe's default base URL ([https://api.poe.com/v1](https://api.poe.com/v1)) ## Basic Text Generation Example using [LanguageModelRequest](https://docs.rs/aisdk/latest/aisdk/core/struct.LanguageModelRequest.html) for text generation. ```rust use aisdk::{ core::LanguageModelRequest, providers::Poe, }; #[tokio::main] async fn main() -> Result<(), Box> { let poe = Poe::anthropic_claude_haiku_3(); let response = LanguageModelRequest::builder() .model(poe) .prompt("Write a short poem about Rust.") .build() .generate_text() .await?; println!("Response text: {:?}", response.text()); Ok(()) } ``` ## Provider Settings You can customize provider configuration using `Poe::builder()` ### API Key ```rust let poe = Poe::::builder() .api_key("your-api-key") .build()?; ``` If not specified, AISDK uses the `POE_API_KEY` environment variable. ### Base URL Useful when routing through a proxy, gateway, or self-hosted compatible endpoint. ```rust let poe = Poe::::builder() .base_url("https://api.poe.com/v1") .build()?; ``` ### Path (Full URL Override) Use `.path(...)` to override the full request URL instead of only the base URL. ```rust let poe = Poe::::builder() .path("https://full-url.example/v1/chat/completions") .build()?; ``` ### Provider Name For logging, analytics, and observability. ```rust let poe = Poe::::builder() .provider_name("Poe") .build()?; ``` ### Full Custom Configuration Example ```rust let poe = Poe::::builder() .api_key("your-api-key") .base_url("https://api.poe.com/v1") .path("https://full-url.example/v1/chat/completions") .provider_name("Poe") .build()?; ``` ## Dynamic Model Selection For runtime model selection (e.g., loading models from config files), use `DynamicModel`: ### Using model\_name() Method with Default Settings ```rust use aisdk::providers::Poe; // Specify model as a string at runtime let poe = Poe::model_name("anthropic/claude-haiku-3"); ``` ### Using Builder Pattern with Custom Settings ```rust use aisdk::{ core::DynamicModel, providers::Poe, }; let poe = Poe::::builder() .model_name("anthropic/claude-haiku-3") .api_key("your-api-key") .base_url("https://api.poe.com/v1") .path("https://full-url.example/v1/chat/completions") .provider_name("Poe") .build()?; ``` **Warning**: When using `DynamicModel`, model capabilities are **not validated at compile time**. This means there's no guarantee the model supports requested features (e.g., tool calls, structured output). For compile-time safety, use the typed methods like `Poe::anthropic_claude_haiku_3()`. ## Next Steps * Take a deeper look at text generation features [Generating Text](/docs/concepts/generating-text#generate_text) / [Streaming Text](/docs/concepts/generating-text#stream_text) * Explore [Structured Output](/docs/concepts/structured-output) for reliable agent data. * Learn how to create [Custom Tools](/docs/concepts/tools). * Learn more about [Agents](/docs/concepts/agents). # Requesty (/docs/providers/requesty) AISDK provides first-class support for Requesty with fully typed model APIs. Model capabilities are enforced at compile time using Rust's type system. This prevents model capability mismatches and guarantees the selected model is valid for the task (e.g. tool calling). ## Installation Enable the Requesty provider feature: ```bash cargo add aisdk --features requesty ``` This installs AISDK with the Requesty provider enabled. Once you have enabled the Requesty provider, you can use all aisdk features with it. ## Create a Provider Instance To create a provider instance, call `Requesty::model_name()`, where **model\_name** is the Requesty model you want to use. Model names are exposed as snake-case methods. ```rust use aisdk::providers::Requesty; let requesty = Requesty::anthropic_claude_3_7_sonnet(); ``` This initializes the provider with: * Model: `"anthropic/claude-3-7-sonnet"` * API key from environment (if set with `REQUESTY_API_KEY`) * Requesty's default base URL ([https://router.requesty.ai/v1](https://router.requesty.ai/v1)) ## Basic Text Generation Example using [LanguageModelRequest](https://docs.rs/aisdk/latest/aisdk/core/struct.LanguageModelRequest.html) for text generation. ```rust use aisdk::{ core::LanguageModelRequest, providers::Requesty, }; #[tokio::main] async fn main() -> Result<(), Box> { let requesty = Requesty::anthropic_claude_3_7_sonnet(); let response = LanguageModelRequest::builder() .model(requesty) .prompt("Write a short poem about Rust.") .build() .generate_text() .await?; println!("Response text: {:?}", response.text()); Ok(()) } ``` ## Provider Settings You can customize provider configuration using `Requesty::builder()` ### API Key ```rust let requesty = Requesty::::builder() .api_key("your-api-key") .build()?; ``` If not specified, AISDK uses the `REQUESTY_API_KEY` environment variable. ### Base URL Useful when routing through a proxy, gateway, or self-hosted compatible endpoint. ```rust let requesty = Requesty::::builder() .base_url("https://router.requesty.ai/v1") .build()?; ``` ### Path (Full URL Override) Use `.path(...)` to override the full request URL instead of only the base URL. ```rust let requesty = Requesty::::builder() .path("https://full-url.example/v1/chat/completions") .build()?; ``` ### Provider Name For logging, analytics, and observability. ```rust let requesty = Requesty::::builder() .provider_name("Requesty") .build()?; ``` ### Full Custom Configuration Example ```rust let requesty = Requesty::::builder() .api_key("your-api-key") .base_url("https://router.requesty.ai/v1") .path("https://full-url.example/v1/chat/completions") .provider_name("Requesty") .build()?; ``` ## Dynamic Model Selection For runtime model selection (e.g., loading models from config files), use `DynamicModel`: ### Using model\_name() Method with Default Settings ```rust use aisdk::providers::Requesty; // Specify model as a string at runtime let requesty = Requesty::model_name("anthropic/claude-3-7-sonnet"); ``` ### Using Builder Pattern with Custom Settings ```rust use aisdk::{ core::DynamicModel, providers::Requesty, }; let requesty = Requesty::::builder() .model_name("anthropic/claude-3-7-sonnet") .api_key("your-api-key") .base_url("https://router.requesty.ai/v1") .path("https://full-url.example/v1/chat/completions") .provider_name("Requesty") .build()?; ``` **Warning**: When using `DynamicModel`, model capabilities are **not validated at compile time**. This means there's no guarantee the model supports requested features (e.g., tool calls, structured output). For compile-time safety, use the typed methods like `Requesty::anthropic_claude_3_7_sonnet()`. ## Next Steps * Take a deeper look at text generation features [Generating Text](/docs/concepts/generating-text#generate_text) / [Streaming Text](/docs/concepts/generating-text#stream_text) * Explore [Structured Output](/docs/concepts/structured-output) for reliable agent data. * Learn how to create [Custom Tools](/docs/concepts/tools). * Learn more about [Agents](/docs/concepts/agents). # Scaleway (/docs/providers/scaleway) AISDK provides first-class support for Scaleway with fully typed model APIs. Model capabilities are enforced at compile time using Rust's type system. This prevents model capability mismatches and guarantees the selected model is valid for the task (e.g. tool calling). ## Installation Enable the Scaleway provider feature: ```bash cargo add aisdk --features scaleway ``` This installs AISDK with the Scaleway provider enabled. Once you have enabled the Scaleway provider, you can use all aisdk features with it. ## Create a Provider Instance To create a provider instance, call `Scaleway::model_name()`, where **model\_name** is the Scaleway model you want to use. Model names are exposed as snake-case methods. ```rust use aisdk::providers::Scaleway; let scaleway = Scaleway::bge_multilingual_gemma2(); ``` This initializes the provider with: * Model: `"bge-multilingual-gemma2"` * API key from environment (if set with `SCALEWAY_API_KEY`) * Scaleway's default base URL ([https://api.scaleway.ai/v1](https://api.scaleway.ai/v1)) ## Basic Text Generation Example using [LanguageModelRequest](https://docs.rs/aisdk/latest/aisdk/core/struct.LanguageModelRequest.html) for text generation. ```rust use aisdk::{ core::LanguageModelRequest, providers::Scaleway, }; #[tokio::main] async fn main() -> Result<(), Box> { let scaleway = Scaleway::bge_multilingual_gemma2(); let response = LanguageModelRequest::builder() .model(scaleway) .prompt("Write a short poem about Rust.") .build() .generate_text() .await?; println!("Response text: {:?}", response.text()); Ok(()) } ``` ## Provider Settings You can customize provider configuration using `Scaleway::builder()` ### API Key ```rust let scaleway = Scaleway::::builder() .api_key("your-api-key") .build()?; ``` If not specified, AISDK uses the `SCALEWAY_API_KEY` environment variable. ### Base URL Useful when routing through a proxy, gateway, or self-hosted compatible endpoint. ```rust let scaleway = Scaleway::::builder() .base_url("https://api.scaleway.ai/v1") .build()?; ``` ### Path (Full URL Override) Use `.path(...)` to override the full request URL instead of only the base URL. ```rust let scaleway = Scaleway::::builder() .path("https://full-url.example/v1/chat/completions") .build()?; ``` ### Provider Name For logging, analytics, and observability. ```rust let scaleway = Scaleway::::builder() .provider_name("Scaleway") .build()?; ``` ### Full Custom Configuration Example ```rust let scaleway = Scaleway::::builder() .api_key("your-api-key") .base_url("https://api.scaleway.ai/v1") .path("https://full-url.example/v1/chat/completions") .provider_name("Scaleway") .build()?; ``` ## Dynamic Model Selection For runtime model selection (e.g., loading models from config files), use `DynamicModel`: ### Using model\_name() Method with Default Settings ```rust use aisdk::providers::Scaleway; // Specify model as a string at runtime let scaleway = Scaleway::model_name("bge-multilingual-gemma2"); ``` ### Using Builder Pattern with Custom Settings ```rust use aisdk::{ core::DynamicModel, providers::Scaleway, }; let scaleway = Scaleway::::builder() .model_name("bge-multilingual-gemma2") .api_key("your-api-key") .base_url("https://api.scaleway.ai/v1") .path("https://full-url.example/v1/chat/completions") .provider_name("Scaleway") .build()?; ``` **Warning**: When using `DynamicModel`, model capabilities are **not validated at compile time**. This means there's no guarantee the model supports requested features (e.g., tool calls, structured output). For compile-time safety, use the typed methods like `Scaleway::bge_multilingual_gemma2()`. ## Next Steps * Take a deeper look at text generation features [Generating Text](/docs/concepts/generating-text#generate_text) / [Streaming Text](/docs/concepts/generating-text#stream_text) * Explore [Structured Output](/docs/concepts/structured-output) for reliable agent data. * Learn how to create [Custom Tools](/docs/concepts/tools). * Learn more about [Agents](/docs/concepts/agents). # SiliconflowCn (/docs/providers/siliconflow-cn) AISDK provides first-class support for SiliconflowCn with fully typed model APIs. Model capabilities are enforced at compile time using Rust's type system. This prevents model capability mismatches and guarantees the selected model is valid for the task (e.g. tool calling). ## Installation Enable the SiliconflowCn provider feature: ```bash cargo add aisdk --features siliconflow-cn ``` This installs AISDK with the SiliconflowCn provider enabled. Once you have enabled the SiliconflowCn provider, you can use all aisdk features with it. ## Create a Provider Instance To create a provider instance, call `SiliconflowCn::model_name()`, where **model\_name** is the SiliconflowCn model you want to use. Model names are exposed as snake-case methods. ```rust use aisdk::providers::SiliconflowCn; let siliconflow-cn = SiliconflowCn::bytedance_seed_seed_oss_36b_instruct(); ``` This initializes the provider with: * Model: `"ByteDance-Seed/Seed-OSS-36B-Instruct"` * API key from environment (if set with `SILICONFLOW_CN_API_KEY`) * SiliconflowCn's default base URL ([https://api.siliconflow.cn/v1](https://api.siliconflow.cn/v1)) ## Basic Text Generation Example using [LanguageModelRequest](https://docs.rs/aisdk/latest/aisdk/core/struct.LanguageModelRequest.html) for text generation. ```rust use aisdk::{ core::LanguageModelRequest, providers::SiliconflowCn, }; #[tokio::main] async fn main() -> Result<(), Box> { let siliconflow-cn = SiliconflowCn::bytedance_seed_seed_oss_36b_instruct(); let response = LanguageModelRequest::builder() .model(siliconflow-cn) .prompt("Write a short poem about Rust.") .build() .generate_text() .await?; println!("Response text: {:?}", response.text()); Ok(()) } ``` ## Provider Settings You can customize provider configuration using `SiliconflowCn::builder()` ### API Key ```rust let siliconflow-cn = SiliconflowCn::::builder() .api_key("your-api-key") .build()?; ``` If not specified, AISDK uses the `SILICONFLOW_CN_API_KEY` environment variable. ### Base URL Useful when routing through a proxy, gateway, or self-hosted compatible endpoint. ```rust let siliconflow-cn = SiliconflowCn::::builder() .base_url("https://api.siliconflow.cn/v1") .build()?; ``` ### Path (Full URL Override) Use `.path(...)` to override the full request URL instead of only the base URL. ```rust let siliconflow-cn = SiliconflowCn::::builder() .path("https://full-url.example/v1/chat/completions") .build()?; ``` ### Provider Name For logging, analytics, and observability. ```rust let siliconflow-cn = SiliconflowCn::::builder() .provider_name("SiliconflowCn") .build()?; ``` ### Full Custom Configuration Example ```rust let siliconflow-cn = SiliconflowCn::::builder() .api_key("your-api-key") .base_url("https://api.siliconflow.cn/v1") .path("https://full-url.example/v1/chat/completions") .provider_name("SiliconflowCn") .build()?; ``` ## Dynamic Model Selection For runtime model selection (e.g., loading models from config files), use `DynamicModel`: ### Using model\_name() Method with Default Settings ```rust use aisdk::providers::SiliconflowCn; // Specify model as a string at runtime let siliconflow-cn = SiliconflowCn::model_name("ByteDance-Seed/Seed-OSS-36B-Instruct"); ``` ### Using Builder Pattern with Custom Settings ```rust use aisdk::{ core::DynamicModel, providers::SiliconflowCn, }; let siliconflow-cn = SiliconflowCn::::builder() .model_name("ByteDance-Seed/Seed-OSS-36B-Instruct") .api_key("your-api-key") .base_url("https://api.siliconflow.cn/v1") .path("https://full-url.example/v1/chat/completions") .provider_name("SiliconflowCn") .build()?; ``` **Warning**: When using `DynamicModel`, model capabilities are **not validated at compile time**. This means there's no guarantee the model supports requested features (e.g., tool calls, structured output). For compile-time safety, use the typed methods like `SiliconflowCn::bytedance_seed_seed_oss_36b_instruct()`. ## Next Steps * Take a deeper look at text generation features [Generating Text](/docs/concepts/generating-text#generate_text) / [Streaming Text](/docs/concepts/generating-text#stream_text) * Explore [Structured Output](/docs/concepts/structured-output) for reliable agent data. * Learn how to create [Custom Tools](/docs/concepts/tools). * Learn more about [Agents](/docs/concepts/agents). # Siliconflow (/docs/providers/siliconflow) AISDK provides first-class support for Siliconflow with fully typed model APIs. Model capabilities are enforced at compile time using Rust's type system. This prevents model capability mismatches and guarantees the selected model is valid for the task (e.g. tool calling). ## Installation Enable the Siliconflow provider feature: ```bash cargo add aisdk --features siliconflow ``` This installs AISDK with the Siliconflow provider enabled. Once you have enabled the Siliconflow provider, you can use all aisdk features with it. ## Create a Provider Instance To create a provider instance, call `Siliconflow::model_name()`, where **model\_name** is the Siliconflow model you want to use. Model names are exposed as snake-case methods. ```rust use aisdk::providers::Siliconflow; let siliconflow = Siliconflow::bytedance_seed_seed_oss_36b_instruct(); ``` This initializes the provider with: * Model: `"ByteDance-Seed/Seed-OSS-36B-Instruct"` * API key from environment (if set with `SILICONFLOW_API_KEY`) * Siliconflow's default base URL ([https://api.siliconflow.com/v1](https://api.siliconflow.com/v1)) ## Basic Text Generation Example using [LanguageModelRequest](https://docs.rs/aisdk/latest/aisdk/core/struct.LanguageModelRequest.html) for text generation. ```rust use aisdk::{ core::LanguageModelRequest, providers::Siliconflow, }; #[tokio::main] async fn main() -> Result<(), Box> { let siliconflow = Siliconflow::bytedance_seed_seed_oss_36b_instruct(); let response = LanguageModelRequest::builder() .model(siliconflow) .prompt("Write a short poem about Rust.") .build() .generate_text() .await?; println!("Response text: {:?}", response.text()); Ok(()) } ``` ## Provider Settings You can customize provider configuration using `Siliconflow::builder()` ### API Key ```rust let siliconflow = Siliconflow::::builder() .api_key("your-api-key") .build()?; ``` If not specified, AISDK uses the `SILICONFLOW_API_KEY` environment variable. ### Base URL Useful when routing through a proxy, gateway, or self-hosted compatible endpoint. ```rust let siliconflow = Siliconflow::::builder() .base_url("https://api.siliconflow.com/v1") .build()?; ``` ### Path (Full URL Override) Use `.path(...)` to override the full request URL instead of only the base URL. ```rust let siliconflow = Siliconflow::::builder() .path("https://full-url.example/v1/chat/completions") .build()?; ``` ### Provider Name For logging, analytics, and observability. ```rust let siliconflow = Siliconflow::::builder() .provider_name("Siliconflow") .build()?; ``` ### Full Custom Configuration Example ```rust let siliconflow = Siliconflow::::builder() .api_key("your-api-key") .base_url("https://api.siliconflow.com/v1") .path("https://full-url.example/v1/chat/completions") .provider_name("Siliconflow") .build()?; ``` ## Dynamic Model Selection For runtime model selection (e.g., loading models from config files), use `DynamicModel`: ### Using model\_name() Method with Default Settings ```rust use aisdk::providers::Siliconflow; // Specify model as a string at runtime let siliconflow = Siliconflow::model_name("ByteDance-Seed/Seed-OSS-36B-Instruct"); ``` ### Using Builder Pattern with Custom Settings ```rust use aisdk::{ core::DynamicModel, providers::Siliconflow, }; let siliconflow = Siliconflow::::builder() .model_name("ByteDance-Seed/Seed-OSS-36B-Instruct") .api_key("your-api-key") .base_url("https://api.siliconflow.com/v1") .path("https://full-url.example/v1/chat/completions") .provider_name("Siliconflow") .build()?; ``` **Warning**: When using `DynamicModel`, model capabilities are **not validated at compile time**. This means there's no guarantee the model supports requested features (e.g., tool calls, structured output). For compile-time safety, use the typed methods like `Siliconflow::bytedance_seed_seed_oss_36b_instruct()`. ## Next Steps * Take a deeper look at text generation features [Generating Text](/docs/concepts/generating-text#generate_text) / [Streaming Text](/docs/concepts/generating-text#stream_text) * Explore [Structured Output](/docs/concepts/structured-output) for reliable agent data. * Learn how to create [Custom Tools](/docs/concepts/tools). * Learn more about [Agents](/docs/concepts/agents). # Stackit (/docs/providers/stackit) AISDK provides first-class support for Stackit with fully typed model APIs. Model capabilities are enforced at compile time using Rust's type system. This prevents model capability mismatches and guarantees the selected model is valid for the task (e.g. tool calling). ## Installation Enable the Stackit provider feature: ```bash cargo add aisdk --features stackit ``` This installs AISDK with the Stackit provider enabled. Once you have enabled the Stackit provider, you can use all aisdk features with it. ## Create a Provider Instance To create a provider instance, call `Stackit::model_name()`, where **model\_name** is the Stackit model you want to use. Model names are exposed as snake-case methods. ```rust use aisdk::providers::Stackit; let stackit = Stackit::qwen_qwen3_vl_235b_a22b_instruct_fp8(); ``` This initializes the provider with: * Model: `"Qwen/Qwen3-VL-235B-A22B-Instruct-FP8"` * API key from environment (if set with `STACKIT_API_KEY`) * Stackit's default base URL ([https://api.openai-compat.model-serving.eu01.onstackit.cloud/v1](https://api.openai-compat.model-serving.eu01.onstackit.cloud/v1)) ## Basic Text Generation Example using [LanguageModelRequest](https://docs.rs/aisdk/latest/aisdk/core/struct.LanguageModelRequest.html) for text generation. ```rust use aisdk::{ core::LanguageModelRequest, providers::Stackit, }; #[tokio::main] async fn main() -> Result<(), Box> { let stackit = Stackit::qwen_qwen3_vl_235b_a22b_instruct_fp8(); let response = LanguageModelRequest::builder() .model(stackit) .prompt("Write a short poem about Rust.") .build() .generate_text() .await?; println!("Response text: {:?}", response.text()); Ok(()) } ``` ## Provider Settings You can customize provider configuration using `Stackit::builder()` ### API Key ```rust let stackit = Stackit::::builder() .api_key("your-api-key") .build()?; ``` If not specified, AISDK uses the `STACKIT_API_KEY` environment variable. ### Base URL Useful when routing through a proxy, gateway, or self-hosted compatible endpoint. ```rust let stackit = Stackit::::builder() .base_url("https://api.openai-compat.model-serving.eu01.onstackit.cloud/v1") .build()?; ``` ### Path (Full URL Override) Use `.path(...)` to override the full request URL instead of only the base URL. ```rust let stackit = Stackit::::builder() .path("https://full-url.example/v1/chat/completions") .build()?; ``` ### Provider Name For logging, analytics, and observability. ```rust let stackit = Stackit::::builder() .provider_name("Stackit") .build()?; ``` ### Full Custom Configuration Example ```rust let stackit = Stackit::::builder() .api_key("your-api-key") .base_url("https://api.openai-compat.model-serving.eu01.onstackit.cloud/v1") .path("https://full-url.example/v1/chat/completions") .provider_name("Stackit") .build()?; ``` ## Dynamic Model Selection For runtime model selection (e.g., loading models from config files), use `DynamicModel`: ### Using model\_name() Method with Default Settings ```rust use aisdk::providers::Stackit; // Specify model as a string at runtime let stackit = Stackit::model_name("Qwen/Qwen3-VL-235B-A22B-Instruct-FP8"); ``` ### Using Builder Pattern with Custom Settings ```rust use aisdk::{ core::DynamicModel, providers::Stackit, }; let stackit = Stackit::::builder() .model_name("Qwen/Qwen3-VL-235B-A22B-Instruct-FP8") .api_key("your-api-key") .base_url("https://api.openai-compat.model-serving.eu01.onstackit.cloud/v1") .path("https://full-url.example/v1/chat/completions") .provider_name("Stackit") .build()?; ``` **Warning**: When using `DynamicModel`, model capabilities are **not validated at compile time**. This means there's no guarantee the model supports requested features (e.g., tool calls, structured output). For compile-time safety, use the typed methods like `Stackit::qwen_qwen3_vl_235b_a22b_instruct_fp8()`. ## Next Steps * Take a deeper look at text generation features [Generating Text](/docs/concepts/generating-text#generate_text) / [Streaming Text](/docs/concepts/generating-text#stream_text) * Explore [Structured Output](/docs/concepts/structured-output) for reliable agent data. * Learn how to create [Custom Tools](/docs/concepts/tools). * Learn more about [Agents](/docs/concepts/agents). # Stepfun (/docs/providers/stepfun) AISDK provides first-class support for Stepfun with fully typed model APIs. Model capabilities are enforced at compile time using Rust's type system. This prevents model capability mismatches and guarantees the selected model is valid for the task (e.g. tool calling). ## Installation Enable the Stepfun provider feature: ```bash cargo add aisdk --features stepfun ``` This installs AISDK with the Stepfun provider enabled. Once you have enabled the Stepfun provider, you can use all aisdk features with it. ## Create a Provider Instance To create a provider instance, call `Stepfun::model_name()`, where **model\_name** is the Stepfun model you want to use. Model names are exposed as snake-case methods. ```rust use aisdk::providers::Stepfun; let stepfun = Stepfun::step_1_32k(); ``` This initializes the provider with: * Model: `"step-1-32k"` * API key from environment (if set with `STEPFUN_API_KEY`) * Stepfun's default base URL ([https://api.stepfun.com/v1](https://api.stepfun.com/v1)) ## Basic Text Generation Example using [LanguageModelRequest](https://docs.rs/aisdk/latest/aisdk/core/struct.LanguageModelRequest.html) for text generation. ```rust use aisdk::{ core::LanguageModelRequest, providers::Stepfun, }; #[tokio::main] async fn main() -> Result<(), Box> { let stepfun = Stepfun::step_1_32k(); let response = LanguageModelRequest::builder() .model(stepfun) .prompt("Write a short poem about Rust.") .build() .generate_text() .await?; println!("Response text: {:?}", response.text()); Ok(()) } ``` ## Provider Settings You can customize provider configuration using `Stepfun::builder()` ### API Key ```rust let stepfun = Stepfun::::builder() .api_key("your-api-key") .build()?; ``` If not specified, AISDK uses the `STEPFUN_API_KEY` environment variable. ### Base URL Useful when routing through a proxy, gateway, or self-hosted compatible endpoint. ```rust let stepfun = Stepfun::::builder() .base_url("https://api.stepfun.com/v1") .build()?; ``` ### Path (Full URL Override) Use `.path(...)` to override the full request URL instead of only the base URL. ```rust let stepfun = Stepfun::::builder() .path("https://full-url.example/v1/chat/completions") .build()?; ``` ### Provider Name For logging, analytics, and observability. ```rust let stepfun = Stepfun::::builder() .provider_name("Stepfun") .build()?; ``` ### Full Custom Configuration Example ```rust let stepfun = Stepfun::::builder() .api_key("your-api-key") .base_url("https://api.stepfun.com/v1") .path("https://full-url.example/v1/chat/completions") .provider_name("Stepfun") .build()?; ``` ## Dynamic Model Selection For runtime model selection (e.g., loading models from config files), use `DynamicModel`: ### Using model\_name() Method with Default Settings ```rust use aisdk::providers::Stepfun; // Specify model as a string at runtime let stepfun = Stepfun::model_name("step-1-32k"); ``` ### Using Builder Pattern with Custom Settings ```rust use aisdk::{ core::DynamicModel, providers::Stepfun, }; let stepfun = Stepfun::::builder() .model_name("step-1-32k") .api_key("your-api-key") .base_url("https://api.stepfun.com/v1") .path("https://full-url.example/v1/chat/completions") .provider_name("Stepfun") .build()?; ``` **Warning**: When using `DynamicModel`, model capabilities are **not validated at compile time**. This means there's no guarantee the model supports requested features (e.g., tool calls, structured output). For compile-time safety, use the typed methods like `Stepfun::step_1_32k()`. ## Next Steps * Take a deeper look at text generation features [Generating Text](/docs/concepts/generating-text#generate_text) / [Streaming Text](/docs/concepts/generating-text#stream_text) * Explore [Structured Output](/docs/concepts/structured-output) for reliable agent data. * Learn how to create [Custom Tools](/docs/concepts/tools). * Learn more about [Agents](/docs/concepts/agents). # Submodel (/docs/providers/submodel) AISDK provides first-class support for Submodel with fully typed model APIs. Model capabilities are enforced at compile time using Rust's type system. This prevents model capability mismatches and guarantees the selected model is valid for the task (e.g. tool calling). ## Installation Enable the Submodel provider feature: ```bash cargo add aisdk --features submodel ``` This installs AISDK with the Submodel provider enabled. Once you have enabled the Submodel provider, you can use all aisdk features with it. ## Create a Provider Instance To create a provider instance, call `Submodel::model_name()`, where **model\_name** is the Submodel model you want to use. Model names are exposed as snake-case methods. ```rust use aisdk::providers::Submodel; let submodel = Submodel::qwen_qwen3_235b_a22b_instruct_2507(); ``` This initializes the provider with: * Model: `"Qwen/Qwen3-235B-A22B-Instruct-2507"` * API key from environment (if set with `SUBMODEL_INSTAGEN_ACCESS_KEY`) * Submodel's default base URL ([https://llm.submodel.ai/v1](https://llm.submodel.ai/v1)) ## Basic Text Generation Example using [LanguageModelRequest](https://docs.rs/aisdk/latest/aisdk/core/struct.LanguageModelRequest.html) for text generation. ```rust use aisdk::{ core::LanguageModelRequest, providers::Submodel, }; #[tokio::main] async fn main() -> Result<(), Box> { let submodel = Submodel::qwen_qwen3_235b_a22b_instruct_2507(); let response = LanguageModelRequest::builder() .model(submodel) .prompt("Write a short poem about Rust.") .build() .generate_text() .await?; println!("Response text: {:?}", response.text()); Ok(()) } ``` ## Provider Settings You can customize provider configuration using `Submodel::builder()` ### API Key ```rust let submodel = Submodel::::builder() .api_key("your-api-key") .build()?; ``` If not specified, AISDK uses the `SUBMODEL_INSTAGEN_ACCESS_KEY` environment variable. ### Base URL Useful when routing through a proxy, gateway, or self-hosted compatible endpoint. ```rust let submodel = Submodel::::builder() .base_url("https://llm.submodel.ai/v1") .build()?; ``` ### Path (Full URL Override) Use `.path(...)` to override the full request URL instead of only the base URL. ```rust let submodel = Submodel::::builder() .path("https://full-url.example/v1/chat/completions") .build()?; ``` ### Provider Name For logging, analytics, and observability. ```rust let submodel = Submodel::::builder() .provider_name("Submodel") .build()?; ``` ### Full Custom Configuration Example ```rust let submodel = Submodel::::builder() .api_key("your-api-key") .base_url("https://llm.submodel.ai/v1") .path("https://full-url.example/v1/chat/completions") .provider_name("Submodel") .build()?; ``` ## Dynamic Model Selection For runtime model selection (e.g., loading models from config files), use `DynamicModel`: ### Using model\_name() Method with Default Settings ```rust use aisdk::providers::Submodel; // Specify model as a string at runtime let submodel = Submodel::model_name("Qwen/Qwen3-235B-A22B-Instruct-2507"); ``` ### Using Builder Pattern with Custom Settings ```rust use aisdk::{ core::DynamicModel, providers::Submodel, }; let submodel = Submodel::::builder() .model_name("Qwen/Qwen3-235B-A22B-Instruct-2507") .api_key("your-api-key") .base_url("https://llm.submodel.ai/v1") .path("https://full-url.example/v1/chat/completions") .provider_name("Submodel") .build()?; ``` **Warning**: When using `DynamicModel`, model capabilities are **not validated at compile time**. This means there's no guarantee the model supports requested features (e.g., tool calls, structured output). For compile-time safety, use the typed methods like `Submodel::qwen_qwen3_235b_a22b_instruct_2507()`. ## Next Steps * Take a deeper look at text generation features [Generating Text](/docs/concepts/generating-text#generate_text) / [Streaming Text](/docs/concepts/generating-text#stream_text) * Explore [Structured Output](/docs/concepts/structured-output) for reliable agent data. * Learn how to create [Custom Tools](/docs/concepts/tools). * Learn more about [Agents](/docs/concepts/agents). # Synthetic (/docs/providers/synthetic) AISDK provides first-class support for Synthetic with fully typed model APIs. Model capabilities are enforced at compile time using Rust's type system. This prevents model capability mismatches and guarantees the selected model is valid for the task (e.g. tool calling). ## Installation Enable the Synthetic provider feature: ```bash cargo add aisdk --features synthetic ``` This installs AISDK with the Synthetic provider enabled. Once you have enabled the Synthetic provider, you can use all aisdk features with it. ## Create a Provider Instance To create a provider instance, call `Synthetic::model_name()`, where **model\_name** is the Synthetic model you want to use. Model names are exposed as snake-case methods. ```rust use aisdk::providers::Synthetic; let synthetic = Synthetic::hf_minimaxai_minimax_m2(); ``` This initializes the provider with: * Model: `"hf:MiniMaxAI/MiniMax-M2"` * API key from environment (if set with `SYNTHETIC_API_KEY`) * Synthetic's default base URL ([https://api.synthetic.new/v1](https://api.synthetic.new/v1)) ## Basic Text Generation Example using [LanguageModelRequest](https://docs.rs/aisdk/latest/aisdk/core/struct.LanguageModelRequest.html) for text generation. ```rust use aisdk::{ core::LanguageModelRequest, providers::Synthetic, }; #[tokio::main] async fn main() -> Result<(), Box> { let synthetic = Synthetic::hf_minimaxai_minimax_m2(); let response = LanguageModelRequest::builder() .model(synthetic) .prompt("Write a short poem about Rust.") .build() .generate_text() .await?; println!("Response text: {:?}", response.text()); Ok(()) } ``` ## Provider Settings You can customize provider configuration using `Synthetic::builder()` ### API Key ```rust let synthetic = Synthetic::::builder() .api_key("your-api-key") .build()?; ``` If not specified, AISDK uses the `SYNTHETIC_API_KEY` environment variable. ### Base URL Useful when routing through a proxy, gateway, or self-hosted compatible endpoint. ```rust let synthetic = Synthetic::::builder() .base_url("https://api.synthetic.new/v1") .build()?; ``` ### Path (Full URL Override) Use `.path(...)` to override the full request URL instead of only the base URL. ```rust let synthetic = Synthetic::::builder() .path("https://full-url.example/v1/chat/completions") .build()?; ``` ### Provider Name For logging, analytics, and observability. ```rust let synthetic = Synthetic::::builder() .provider_name("Synthetic") .build()?; ``` ### Full Custom Configuration Example ```rust let synthetic = Synthetic::::builder() .api_key("your-api-key") .base_url("https://api.synthetic.new/v1") .path("https://full-url.example/v1/chat/completions") .provider_name("Synthetic") .build()?; ``` ## Dynamic Model Selection For runtime model selection (e.g., loading models from config files), use `DynamicModel`: ### Using model\_name() Method with Default Settings ```rust use aisdk::providers::Synthetic; // Specify model as a string at runtime let synthetic = Synthetic::model_name("hf:MiniMaxAI/MiniMax-M2"); ``` ### Using Builder Pattern with Custom Settings ```rust use aisdk::{ core::DynamicModel, providers::Synthetic, }; let synthetic = Synthetic::::builder() .model_name("hf:MiniMaxAI/MiniMax-M2") .api_key("your-api-key") .base_url("https://api.synthetic.new/v1") .path("https://full-url.example/v1/chat/completions") .provider_name("Synthetic") .build()?; ``` **Warning**: When using `DynamicModel`, model capabilities are **not validated at compile time**. This means there's no guarantee the model supports requested features (e.g., tool calls, structured output). For compile-time safety, use the typed methods like `Synthetic::hf_minimaxai_minimax_m2()`. ## Next Steps * Take a deeper look at text generation features [Generating Text](/docs/concepts/generating-text#generate_text) / [Streaming Text](/docs/concepts/generating-text#stream_text) * Explore [Structured Output](/docs/concepts/structured-output) for reliable agent data. * Learn how to create [Custom Tools](/docs/concepts/tools). * Learn more about [Agents](/docs/concepts/agents). # TogetherAI (/docs/providers/togetherai) AISDK provides first-class support for TogetherAI with fully typed model APIs. Model capabilities are enforced at compile time using Rust's type system. This prevents model capability mismatches and guarantees the selected model is valid for the task (e.g. tool calling). ## Installation Enable the TogetherAI provider feature: ```bash cargo add aisdk --features togetherai ``` This installs AISDK with the TogetherAI provider enabled. Once you have enabled the TogetherAI provider, you can use all aisdk features with it. ## Create a Provider Instance To create a provider instance, call `TogetherAI::model_name()`, where **model\_name** is the TogetherAI model you want to use. Model names are exposed as snake-case methods. ```rust use aisdk::providers::TogetherAI; let togetherai = TogetherAI::deepseek_ai_deepseek_r1(); ``` This initializes the provider with: * Model: `"deepseek-ai/DeepSeek-R1"` * API key from environment (if set with `TOGETHER_API_KEY`) * TogetherAI's default base URL ([https://api.together.xyz/v1/](https://api.together.xyz/v1/)) ## Basic Text Generation Example using [LanguageModelRequest](https://docs.rs/aisdk/latest/aisdk/core/struct.LanguageModelRequest.html) for text generation. ```rust use aisdk::{ core::LanguageModelRequest, providers::TogetherAI, }; #[tokio::main] async fn main() -> Result<(), Box> { let togetherai = TogetherAI::deepseek_ai_deepseek_r1(); let response = LanguageModelRequest::builder() .model(togetherai) .prompt("Write a short poem about Rust.") .build() .generate_text() .await?; println!("Response text: {:?}", response.text()); Ok(()) } ``` ## Provider Settings You can customize provider configuration using `TogetherAI::builder()` ### API Key ```rust let togetherai = TogetherAI::::builder() .api_key("your-api-key") .build()?; ``` If not specified, AISDK uses the `TOGETHER_API_KEY` environment variable. ### Base URL Useful when routing through a proxy, gateway, or self-hosted compatible endpoint. ```rust let togetherai = TogetherAI::::builder() .base_url("https://api.together.xyz/v1/") .build()?; ``` ### Path (Full URL Override) Use `.path(...)` to override the full request URL instead of only the base URL. ```rust let togetherai = TogetherAI::::builder() .path("https://full-url.example/v1/chat/completions") .build()?; ``` ### Provider Name For logging, analytics, and observability. ```rust let togetherai = TogetherAI::::builder() .provider_name("TogetherAI") .build()?; ``` ### Full Custom Configuration Example ```rust let togetherai = TogetherAI::::builder() .api_key("your-api-key") .base_url("https://api.together.xyz/v1/") .path("https://full-url.example/v1/chat/completions") .provider_name("TogetherAI") .build()?; ``` ## Dynamic Model Selection For runtime model selection (e.g., loading models from config files), use `DynamicModel`: ### Using model\_name() Method with Default Settings ```rust use aisdk::providers::TogetherAI; // Specify model as a string at runtime let togetherai = TogetherAI::model_name("deepseek-ai/DeepSeek-R1"); ``` ### Using Builder Pattern with Custom Settings ```rust use aisdk::{ core::DynamicModel, providers::TogetherAI, }; let togetherai = TogetherAI::::builder() .model_name("deepseek-ai/DeepSeek-R1") .api_key("your-api-key") .base_url("https://api.together.xyz/v1/") .path("https://full-url.example/v1/chat/completions") .provider_name("TogetherAI") .build()?; ``` **Warning**: When using `DynamicModel`, model capabilities are **not validated at compile time**. This means there's no guarantee the model supports requested features (e.g., tool calls, structured output). For compile-time safety, use the typed methods like `TogetherAI::deepseek_ai_deepseek_r1()`. ## Next Steps * Take a deeper look at text generation features [Generating Text](/docs/concepts/generating-text#generate_text) / [Streaming Text](/docs/concepts/generating-text#stream_text) * Explore [Structured Output](/docs/concepts/structured-output) for reliable agent data. * Learn how to create [Custom Tools](/docs/concepts/tools). * Learn more about [Agents](/docs/concepts/agents). # Upstage (/docs/providers/upstage) AISDK provides first-class support for Upstage with fully typed model APIs. Model capabilities are enforced at compile time using Rust's type system. This prevents model capability mismatches and guarantees the selected model is valid for the task (e.g. tool calling). ## Installation Enable the Upstage provider feature: ```bash cargo add aisdk --features upstage ``` This installs AISDK with the Upstage provider enabled. Once you have enabled the Upstage provider, you can use all aisdk features with it. ## Create a Provider Instance To create a provider instance, call `Upstage::model_name()`, where **model\_name** is the Upstage model you want to use. Model names are exposed as snake-case methods. ```rust use aisdk::providers::Upstage; let upstage = Upstage::solar_mini(); ``` This initializes the provider with: * Model: `"solar-mini"` * API key from environment (if set with `UPSTAGE_API_KEY`) * Upstage's default base URL ([https://api.upstage.ai/v1/solar](https://api.upstage.ai/v1/solar)) ## Basic Text Generation Example using [LanguageModelRequest](https://docs.rs/aisdk/latest/aisdk/core/struct.LanguageModelRequest.html) for text generation. ```rust use aisdk::{ core::LanguageModelRequest, providers::Upstage, }; #[tokio::main] async fn main() -> Result<(), Box> { let upstage = Upstage::solar_mini(); let response = LanguageModelRequest::builder() .model(upstage) .prompt("Write a short poem about Rust.") .build() .generate_text() .await?; println!("Response text: {:?}", response.text()); Ok(()) } ``` ## Provider Settings You can customize provider configuration using `Upstage::builder()` ### API Key ```rust let upstage = Upstage::::builder() .api_key("your-api-key") .build()?; ``` If not specified, AISDK uses the `UPSTAGE_API_KEY` environment variable. ### Base URL Useful when routing through a proxy, gateway, or self-hosted compatible endpoint. ```rust let upstage = Upstage::::builder() .base_url("https://api.upstage.ai/v1/solar") .build()?; ``` ### Path (Full URL Override) Use `.path(...)` to override the full request URL instead of only the base URL. ```rust let upstage = Upstage::::builder() .path("https://full-url.example/v1/chat/completions") .build()?; ``` ### Provider Name For logging, analytics, and observability. ```rust let upstage = Upstage::::builder() .provider_name("Upstage") .build()?; ``` ### Full Custom Configuration Example ```rust let upstage = Upstage::::builder() .api_key("your-api-key") .base_url("https://api.upstage.ai/v1/solar") .path("https://full-url.example/v1/chat/completions") .provider_name("Upstage") .build()?; ``` ## Dynamic Model Selection For runtime model selection (e.g., loading models from config files), use `DynamicModel`: ### Using model\_name() Method with Default Settings ```rust use aisdk::providers::Upstage; // Specify model as a string at runtime let upstage = Upstage::model_name("solar-mini"); ``` ### Using Builder Pattern with Custom Settings ```rust use aisdk::{ core::DynamicModel, providers::Upstage, }; let upstage = Upstage::::builder() .model_name("solar-mini") .api_key("your-api-key") .base_url("https://api.upstage.ai/v1/solar") .path("https://full-url.example/v1/chat/completions") .provider_name("Upstage") .build()?; ``` **Warning**: When using `DynamicModel`, model capabilities are **not validated at compile time**. This means there's no guarantee the model supports requested features (e.g., tool calls, structured output). For compile-time safety, use the typed methods like `Upstage::solar_mini()`. ## Next Steps * Take a deeper look at text generation features [Generating Text](/docs/concepts/generating-text#generate_text) / [Streaming Text](/docs/concepts/generating-text#stream_text) * Explore [Structured Output](/docs/concepts/structured-output) for reliable agent data. * Learn how to create [Custom Tools](/docs/concepts/tools). * Learn more about [Agents](/docs/concepts/agents). # Vercel (/docs/providers/vercel) AISDK provides first-class support for Vercel with fully typed model APIs. Model capabilities are enforced at compile time using Rust's type system. This prevents model capability mismatches and guarantees the selected model is valid for the task (e.g. tool calling). ## Installation Enable the Vercel provider feature: ```bash cargo add aisdk --features vercel ``` This installs AISDK with the Vercel provider enabled. Once you have enabled the Vercel provider, you can use all aisdk features with it. ## Create a Provider Instance To create a provider instance, call `Vercel::model_name()`, where **model\_name** is the Vercel model you want to use. Model names are exposed as snake-case methods. ```rust use aisdk::providers::Vercel; let vercel = Vercel::alibaba_qwen_3_14b(); ``` This initializes the provider with: * Model: `"alibaba/qwen-3-14b"` * API key from environment (if set with `VERCEL_API_KEY`) * Vercel's default base URL ([https://ai-gateway.vercel.sh/v1/](https://ai-gateway.vercel.sh/v1/)) ## Basic Text Generation Example using [LanguageModelRequest](https://docs.rs/aisdk/latest/aisdk/core/struct.LanguageModelRequest.html) for text generation. ```rust use aisdk::{ core::LanguageModelRequest, providers::Vercel, }; #[tokio::main] async fn main() -> Result<(), Box> { let vercel = Vercel::alibaba_qwen_3_14b(); let response = LanguageModelRequest::builder() .model(vercel) .prompt("Write a short poem about Rust.") .build() .generate_text() .await?; println!("Response text: {:?}", response.text()); Ok(()) } ``` ## Provider Settings You can customize provider configuration using `Vercel::builder()` ### API Key ```rust let vercel = Vercel::::builder() .api_key("your-api-key") .build()?; ``` If not specified, AISDK uses the `VERCEL_API_KEY` environment variable. ### Base URL Useful when routing through a proxy, gateway, or self-hosted compatible endpoint. ```rust let vercel = Vercel::::builder() .base_url("https://ai-gateway.vercel.sh/v1/") .build()?; ``` ### Path (Full URL Override) Use `.path(...)` to override the full request URL instead of only the base URL. ```rust let vercel = Vercel::::builder() .path("https://full-url.example/v1/chat/completions") .build()?; ``` ### Provider Name For logging, analytics, and observability. ```rust let vercel = Vercel::::builder() .provider_name("Vercel") .build()?; ``` ### Full Custom Configuration Example ```rust let vercel = Vercel::::builder() .api_key("your-api-key") .base_url("https://ai-gateway.vercel.sh/v1/") .path("https://full-url.example/v1/chat/completions") .provider_name("Vercel") .build()?; ``` ## Dynamic Model Selection For runtime model selection (e.g., loading models from config files), use `DynamicModel`: ### Using model\_name() Method with Default Settings ```rust use aisdk::providers::Vercel; // Specify model as a string at runtime let vercel = Vercel::model_name("alibaba/qwen-3-14b"); ``` ### Using Builder Pattern with Custom Settings ```rust use aisdk::{ core::DynamicModel, providers::Vercel, }; let vercel = Vercel::::builder() .model_name("alibaba/qwen-3-14b") .api_key("your-api-key") .base_url("https://ai-gateway.vercel.sh/v1/") .path("https://full-url.example/v1/chat/completions") .provider_name("Vercel") .build()?; ``` **Warning**: When using `DynamicModel`, model capabilities are **not validated at compile time**. This means there's no guarantee the model supports requested features (e.g., tool calls, structured output). For compile-time safety, use the typed methods like `Vercel::alibaba_qwen_3_14b()`. ## Next Steps * Take a deeper look at text generation features [Generating Text](/docs/concepts/generating-text#generate_text) / [Streaming Text](/docs/concepts/generating-text#stream_text) * Explore [Structured Output](/docs/concepts/structured-output) for reliable agent data. * Learn how to create [Custom Tools](/docs/concepts/tools). * Learn more about [Agents](/docs/concepts/agents). # Vultr (/docs/providers/vultr) AISDK provides first-class support for Vultr with fully typed model APIs. Model capabilities are enforced at compile time using Rust's type system. This prevents model capability mismatches and guarantees the selected model is valid for the task (e.g. tool calling). ## Installation Enable the Vultr provider feature: ```bash cargo add aisdk --features vultr ``` This installs AISDK with the Vultr provider enabled. Once you have enabled the Vultr provider, you can use all aisdk features with it. ## Create a Provider Instance To create a provider instance, call `Vultr::model_name()`, where **model\_name** is the Vultr model you want to use. Model names are exposed as snake-case methods. ```rust use aisdk::providers::Vultr; let vultr = Vultr::deepseek_r1_distill_llama_70b(); ``` This initializes the provider with: * Model: `"deepseek-r1-distill-llama-70b"` * API key from environment (if set with `VULTR_API_KEY`) * Vultr's default base URL ([https://api.vultrinference.com/v1](https://api.vultrinference.com/v1)) ## Basic Text Generation Example using [LanguageModelRequest](https://docs.rs/aisdk/latest/aisdk/core/struct.LanguageModelRequest.html) for text generation. ```rust use aisdk::{ core::LanguageModelRequest, providers::Vultr, }; #[tokio::main] async fn main() -> Result<(), Box> { let vultr = Vultr::deepseek_r1_distill_llama_70b(); let response = LanguageModelRequest::builder() .model(vultr) .prompt("Write a short poem about Rust.") .build() .generate_text() .await?; println!("Response text: {:?}", response.text()); Ok(()) } ``` ## Provider Settings You can customize provider configuration using `Vultr::builder()` ### API Key ```rust let vultr = Vultr::::builder() .api_key("your-api-key") .build()?; ``` If not specified, AISDK uses the `VULTR_API_KEY` environment variable. ### Base URL Useful when routing through a proxy, gateway, or self-hosted compatible endpoint. ```rust let vultr = Vultr::::builder() .base_url("https://api.vultrinference.com/v1") .build()?; ``` ### Path (Full URL Override) Use `.path(...)` to override the full request URL instead of only the base URL. ```rust let vultr = Vultr::::builder() .path("https://full-url.example/v1/chat/completions") .build()?; ``` ### Provider Name For logging, analytics, and observability. ```rust let vultr = Vultr::::builder() .provider_name("Vultr") .build()?; ``` ### Full Custom Configuration Example ```rust let vultr = Vultr::::builder() .api_key("your-api-key") .base_url("https://api.vultrinference.com/v1") .path("https://full-url.example/v1/chat/completions") .provider_name("Vultr") .build()?; ``` ## Dynamic Model Selection For runtime model selection (e.g., loading models from config files), use `DynamicModel`: ### Using model\_name() Method with Default Settings ```rust use aisdk::providers::Vultr; // Specify model as a string at runtime let vultr = Vultr::model_name("deepseek-r1-distill-llama-70b"); ``` ### Using Builder Pattern with Custom Settings ```rust use aisdk::{ core::DynamicModel, providers::Vultr, }; let vultr = Vultr::::builder() .model_name("deepseek-r1-distill-llama-70b") .api_key("your-api-key") .base_url("https://api.vultrinference.com/v1") .path("https://full-url.example/v1/chat/completions") .provider_name("Vultr") .build()?; ``` **Warning**: When using `DynamicModel`, model capabilities are **not validated at compile time**. This means there's no guarantee the model supports requested features (e.g., tool calls, structured output). For compile-time safety, use the typed methods like `Vultr::deepseek_r1_distill_llama_70b()`. ## Next Steps * Take a deeper look at text generation features [Generating Text](/docs/concepts/generating-text#generate_text) / [Streaming Text](/docs/concepts/generating-text#stream_text) * Explore [Structured Output](/docs/concepts/structured-output) for reliable agent data. * Learn how to create [Custom Tools](/docs/concepts/tools). * Learn more about [Agents](/docs/concepts/agents). # Wandb (/docs/providers/wandb) AISDK provides first-class support for Wandb with fully typed model APIs. Model capabilities are enforced at compile time using Rust's type system. This prevents model capability mismatches and guarantees the selected model is valid for the task (e.g. tool calling). ## Installation Enable the Wandb provider feature: ```bash cargo add aisdk --features wandb ``` This installs AISDK with the Wandb provider enabled. Once you have enabled the Wandb provider, you can use all aisdk features with it. ## Create a Provider Instance To create a provider instance, call `Wandb::model_name()`, where **model\_name** is the Wandb model you want to use. Model names are exposed as snake-case methods. ```rust use aisdk::providers::Wandb; let wandb = Wandb::qwen_qwen3_235b_a22b_instruct_2507(); ``` This initializes the provider with: * Model: `"Qwen/Qwen3-235B-A22B-Instruct-2507"` * API key from environment (if set with `WANDB_API_KEY`) * Wandb's default base URL ([https://api.inference.wandb.ai/v1](https://api.inference.wandb.ai/v1)) ## Basic Text Generation Example using [LanguageModelRequest](https://docs.rs/aisdk/latest/aisdk/core/struct.LanguageModelRequest.html) for text generation. ```rust use aisdk::{ core::LanguageModelRequest, providers::Wandb, }; #[tokio::main] async fn main() -> Result<(), Box> { let wandb = Wandb::qwen_qwen3_235b_a22b_instruct_2507(); let response = LanguageModelRequest::builder() .model(wandb) .prompt("Write a short poem about Rust.") .build() .generate_text() .await?; println!("Response text: {:?}", response.text()); Ok(()) } ``` ## Provider Settings You can customize provider configuration using `Wandb::builder()` ### API Key ```rust let wandb = Wandb::::builder() .api_key("your-api-key") .build()?; ``` If not specified, AISDK uses the `WANDB_API_KEY` environment variable. ### Base URL Useful when routing through a proxy, gateway, or self-hosted compatible endpoint. ```rust let wandb = Wandb::::builder() .base_url("https://api.inference.wandb.ai/v1") .build()?; ``` ### Path (Full URL Override) Use `.path(...)` to override the full request URL instead of only the base URL. ```rust let wandb = Wandb::::builder() .path("https://full-url.example/v1/chat/completions") .build()?; ``` ### Provider Name For logging, analytics, and observability. ```rust let wandb = Wandb::::builder() .provider_name("Wandb") .build()?; ``` ### Full Custom Configuration Example ```rust let wandb = Wandb::::builder() .api_key("your-api-key") .base_url("https://api.inference.wandb.ai/v1") .path("https://full-url.example/v1/chat/completions") .provider_name("Wandb") .build()?; ``` ## Dynamic Model Selection For runtime model selection (e.g., loading models from config files), use `DynamicModel`: ### Using model\_name() Method with Default Settings ```rust use aisdk::providers::Wandb; // Specify model as a string at runtime let wandb = Wandb::model_name("Qwen/Qwen3-235B-A22B-Instruct-2507"); ``` ### Using Builder Pattern with Custom Settings ```rust use aisdk::{ core::DynamicModel, providers::Wandb, }; let wandb = Wandb::::builder() .model_name("Qwen/Qwen3-235B-A22B-Instruct-2507") .api_key("your-api-key") .base_url("https://api.inference.wandb.ai/v1") .path("https://full-url.example/v1/chat/completions") .provider_name("Wandb") .build()?; ``` **Warning**: When using `DynamicModel`, model capabilities are **not validated at compile time**. This means there's no guarantee the model supports requested features (e.g., tool calls, structured output). For compile-time safety, use the typed methods like `Wandb::qwen_qwen3_235b_a22b_instruct_2507()`. ## Next Steps * Take a deeper look at text generation features [Generating Text](/docs/concepts/generating-text#generate_text) / [Streaming Text](/docs/concepts/generating-text#stream_text) * Explore [Structured Output](/docs/concepts/structured-output) for reliable agent data. * Learn how to create [Custom Tools](/docs/concepts/tools). * Learn more about [Agents](/docs/concepts/agents). # XAI (/docs/providers/xai) AISDK provides first-class support for XAI with fully typed model APIs. Model capabilities are enforced at compile time using Rust's type system. This prevents model capability mismatches and guarantees the selected model is valid for the task (e.g. tool calling). ## Installation Enable the XAI provider feature: ```bash cargo add aisdk --features xai ``` This installs AISDK with the XAI provider enabled. Once you have enabled the XAI provider, you can use all aisdk features with it. ## Create a Provider Instance To create a provider instance, call `XAI::model_name()`, where **model\_name** is the XAI model you want to use. Model names are exposed as snake-case methods. ```rust use aisdk::providers::XAI; let xai = XAI::grok_2(); ``` This initializes the provider with: * Model: `"grok-2"` * API key from environment (if set with `XAI_API_KEY`) * XAI's default base URL ([https://api.x.ai/v1/](https://api.x.ai/v1/)) ## Basic Text Generation Example using [LanguageModelRequest](https://docs.rs/aisdk/latest/aisdk/core/struct.LanguageModelRequest.html) for text generation. ```rust use aisdk::{ core::LanguageModelRequest, providers::XAI, }; #[tokio::main] async fn main() -> Result<(), Box> { let xai = XAI::grok_2(); let response = LanguageModelRequest::builder() .model(xai) .prompt("Write a short poem about Rust.") .build() .generate_text() .await?; println!("Response text: {:?}", response.text()); Ok(()) } ``` ## Provider Settings You can customize provider configuration using `XAI::builder()` ### API Key ```rust let xai = XAI::::builder() .api_key("your-api-key") .build()?; ``` If not specified, AISDK uses the `XAI_API_KEY` environment variable. ### Base URL Useful when routing through a proxy, gateway, or self-hosted compatible endpoint. ```rust let xai = XAI::::builder() .base_url("https://api.x.ai/v1/") .build()?; ``` ### Path (Full URL Override) Use `.path(...)` to override the full request URL instead of only the base URL. ```rust let xai = XAI::::builder() .path("https://full-url.example/v1/chat/completions") .build()?; ``` ### Provider Name For logging, analytics, and observability. ```rust let xai = XAI::::builder() .provider_name("XAI") .build()?; ``` ### Full Custom Configuration Example ```rust let xai = XAI::::builder() .api_key("your-api-key") .base_url("https://api.x.ai/v1/") .path("https://full-url.example/v1/chat/completions") .provider_name("XAI") .build()?; ``` ## Dynamic Model Selection For runtime model selection (e.g., loading models from config files), use `DynamicModel`: ### Using model\_name() Method with Default Settings ```rust use aisdk::providers::XAI; // Specify model as a string at runtime let xai = XAI::model_name("grok-2"); ``` ### Using Builder Pattern with Custom Settings ```rust use aisdk::{ core::DynamicModel, providers::XAI, }; let xai = XAI::::builder() .model_name("grok-2") .api_key("your-api-key") .base_url("https://api.x.ai/v1/") .path("https://full-url.example/v1/chat/completions") .provider_name("XAI") .build()?; ``` **Warning**: When using `DynamicModel`, model capabilities are **not validated at compile time**. This means there's no guarantee the model supports requested features (e.g., tool calls, structured output). For compile-time safety, use the typed methods like `XAI::grok_2()`. ## Next Steps * Take a deeper look at text generation features [Generating Text](/docs/concepts/generating-text#generate_text) / [Streaming Text](/docs/concepts/generating-text#stream_text) * Explore [Structured Output](/docs/concepts/structured-output) for reliable agent data. * Learn how to create [Custom Tools](/docs/concepts/tools). * Learn more about [Agents](/docs/concepts/agents). # Xiaomi (/docs/providers/xiaomi) AISDK provides first-class support for Xiaomi with fully typed model APIs. Model capabilities are enforced at compile time using Rust's type system. This prevents model capability mismatches and guarantees the selected model is valid for the task (e.g. tool calling). ## Installation Enable the Xiaomi provider feature: ```bash cargo add aisdk --features xiaomi ``` This installs AISDK with the Xiaomi provider enabled. Once you have enabled the Xiaomi provider, you can use all aisdk features with it. ## Create a Provider Instance To create a provider instance, call `Xiaomi::model_name()`, where **model\_name** is the Xiaomi model you want to use. Model names are exposed as snake-case methods. ```rust use aisdk::providers::Xiaomi; let xiaomi = Xiaomi::mimo_v2_flash(); ``` This initializes the provider with: * Model: `"mimo-v2-flash"` * API key from environment (if set with `XIAOMI_API_KEY`) * Xiaomi's default base URL ([https://api.xiaomimimo.com/v1](https://api.xiaomimimo.com/v1)) ## Basic Text Generation Example using [LanguageModelRequest](https://docs.rs/aisdk/latest/aisdk/core/struct.LanguageModelRequest.html) for text generation. ```rust use aisdk::{ core::LanguageModelRequest, providers::Xiaomi, }; #[tokio::main] async fn main() -> Result<(), Box> { let xiaomi = Xiaomi::mimo_v2_flash(); let response = LanguageModelRequest::builder() .model(xiaomi) .prompt("Write a short poem about Rust.") .build() .generate_text() .await?; println!("Response text: {:?}", response.text()); Ok(()) } ``` ## Provider Settings You can customize provider configuration using `Xiaomi::builder()` ### API Key ```rust let xiaomi = Xiaomi::::builder() .api_key("your-api-key") .build()?; ``` If not specified, AISDK uses the `XIAOMI_API_KEY` environment variable. ### Base URL Useful when routing through a proxy, gateway, or self-hosted compatible endpoint. ```rust let xiaomi = Xiaomi::::builder() .base_url("https://api.xiaomimimo.com/v1") .build()?; ``` ### Path (Full URL Override) Use `.path(...)` to override the full request URL instead of only the base URL. ```rust let xiaomi = Xiaomi::::builder() .path("https://full-url.example/v1/chat/completions") .build()?; ``` ### Provider Name For logging, analytics, and observability. ```rust let xiaomi = Xiaomi::::builder() .provider_name("Xiaomi") .build()?; ``` ### Full Custom Configuration Example ```rust let xiaomi = Xiaomi::::builder() .api_key("your-api-key") .base_url("https://api.xiaomimimo.com/v1") .path("https://full-url.example/v1/chat/completions") .provider_name("Xiaomi") .build()?; ``` ## Dynamic Model Selection For runtime model selection (e.g., loading models from config files), use `DynamicModel`: ### Using model\_name() Method with Default Settings ```rust use aisdk::providers::Xiaomi; // Specify model as a string at runtime let xiaomi = Xiaomi::model_name("mimo-v2-flash"); ``` ### Using Builder Pattern with Custom Settings ```rust use aisdk::{ core::DynamicModel, providers::Xiaomi, }; let xiaomi = Xiaomi::::builder() .model_name("mimo-v2-flash") .api_key("your-api-key") .base_url("https://api.xiaomimimo.com/v1") .path("https://full-url.example/v1/chat/completions") .provider_name("Xiaomi") .build()?; ``` **Warning**: When using `DynamicModel`, model capabilities are **not validated at compile time**. This means there's no guarantee the model supports requested features (e.g., tool calls, structured output). For compile-time safety, use the typed methods like `Xiaomi::mimo_v2_flash()`. ## Next Steps * Take a deeper look at text generation features [Generating Text](/docs/concepts/generating-text#generate_text) / [Streaming Text](/docs/concepts/generating-text#stream_text) * Explore [Structured Output](/docs/concepts/structured-output) for reliable agent data. * Learn how to create [Custom Tools](/docs/concepts/tools). * Learn more about [Agents](/docs/concepts/agents). # ZaiCodingPlan (/docs/providers/zai-coding-plan) AISDK provides first-class support for ZaiCodingPlan with fully typed model APIs. Model capabilities are enforced at compile time using Rust's type system. This prevents model capability mismatches and guarantees the selected model is valid for the task (e.g. tool calling). ## Installation Enable the ZaiCodingPlan provider feature: ```bash cargo add aisdk --features zai-coding-plan ``` This installs AISDK with the ZaiCodingPlan provider enabled. Once you have enabled the ZaiCodingPlan provider, you can use all aisdk features with it. ## Create a Provider Instance To create a provider instance, call `ZaiCodingPlan::model_name()`, where **model\_name** is the ZaiCodingPlan model you want to use. Model names are exposed as snake-case methods. ```rust use aisdk::providers::ZaiCodingPlan; let zai-coding-plan = ZaiCodingPlan::glm_4_5(); ``` This initializes the provider with: * Model: `"glm-4.5"` * API key from environment (if set with `ZHIPU_API_KEY`) * ZaiCodingPlan's default base URL ([https://api.z.ai/api/coding/paas/v4](https://api.z.ai/api/coding/paas/v4)) ## Basic Text Generation Example using [LanguageModelRequest](https://docs.rs/aisdk/latest/aisdk/core/struct.LanguageModelRequest.html) for text generation. ```rust use aisdk::{ core::LanguageModelRequest, providers::ZaiCodingPlan, }; #[tokio::main] async fn main() -> Result<(), Box> { let zai-coding-plan = ZaiCodingPlan::glm_4_5(); let response = LanguageModelRequest::builder() .model(zai-coding-plan) .prompt("Write a short poem about Rust.") .build() .generate_text() .await?; println!("Response text: {:?}", response.text()); Ok(()) } ``` ## Provider Settings You can customize provider configuration using `ZaiCodingPlan::builder()` ### API Key ```rust let zai-coding-plan = ZaiCodingPlan::::builder() .api_key("your-api-key") .build()?; ``` If not specified, AISDK uses the `ZHIPU_API_KEY` environment variable. ### Base URL Useful when routing through a proxy, gateway, or self-hosted compatible endpoint. ```rust let zai-coding-plan = ZaiCodingPlan::::builder() .base_url("https://api.z.ai/api/coding/paas/v4") .build()?; ``` ### Path (Full URL Override) Use `.path(...)` to override the full request URL instead of only the base URL. ```rust let zai-coding-plan = ZaiCodingPlan::::builder() .path("https://full-url.example/v1/chat/completions") .build()?; ``` ### Provider Name For logging, analytics, and observability. ```rust let zai-coding-plan = ZaiCodingPlan::::builder() .provider_name("ZaiCodingPlan") .build()?; ``` ### Full Custom Configuration Example ```rust let zai-coding-plan = ZaiCodingPlan::::builder() .api_key("your-api-key") .base_url("https://api.z.ai/api/coding/paas/v4") .path("https://full-url.example/v1/chat/completions") .provider_name("ZaiCodingPlan") .build()?; ``` ## Dynamic Model Selection For runtime model selection (e.g., loading models from config files), use `DynamicModel`: ### Using model\_name() Method with Default Settings ```rust use aisdk::providers::ZaiCodingPlan; // Specify model as a string at runtime let zai-coding-plan = ZaiCodingPlan::model_name("glm-4.5"); ``` ### Using Builder Pattern with Custom Settings ```rust use aisdk::{ core::DynamicModel, providers::ZaiCodingPlan, }; let zai-coding-plan = ZaiCodingPlan::::builder() .model_name("glm-4.5") .api_key("your-api-key") .base_url("https://api.z.ai/api/coding/paas/v4") .path("https://full-url.example/v1/chat/completions") .provider_name("ZaiCodingPlan") .build()?; ``` **Warning**: When using `DynamicModel`, model capabilities are **not validated at compile time**. This means there's no guarantee the model supports requested features (e.g., tool calls, structured output). For compile-time safety, use the typed methods like `ZaiCodingPlan::glm_4_5()`. ## Next Steps * Take a deeper look at text generation features [Generating Text](/docs/concepts/generating-text#generate_text) / [Streaming Text](/docs/concepts/generating-text#stream_text) * Explore [Structured Output](/docs/concepts/structured-output) for reliable agent data. * Learn how to create [Custom Tools](/docs/concepts/tools). * Learn more about [Agents](/docs/concepts/agents). # Zai (/docs/providers/zai) AISDK provides first-class support for Zai with fully typed model APIs. Model capabilities are enforced at compile time using Rust's type system. This prevents model capability mismatches and guarantees the selected model is valid for the task (e.g. tool calling). ## Installation Enable the Zai provider feature: ```bash cargo add aisdk --features zai ``` This installs AISDK with the Zai provider enabled. Once you have enabled the Zai provider, you can use all aisdk features with it. ## Create a Provider Instance To create a provider instance, call `Zai::model_name()`, where **model\_name** is the Zai model you want to use. Model names are exposed as snake-case methods. ```rust use aisdk::providers::Zai; let zai = Zai::glm_4_5(); ``` This initializes the provider with: * Model: `"glm-4.5"` * API key from environment (if set with `ZHIPU_API_KEY`) * Zai's default base URL ([https://api.z.ai/api/paas/v4](https://api.z.ai/api/paas/v4)) ## Basic Text Generation Example using [LanguageModelRequest](https://docs.rs/aisdk/latest/aisdk/core/struct.LanguageModelRequest.html) for text generation. ```rust use aisdk::{ core::LanguageModelRequest, providers::Zai, }; #[tokio::main] async fn main() -> Result<(), Box> { let zai = Zai::glm_4_5(); let response = LanguageModelRequest::builder() .model(zai) .prompt("Write a short poem about Rust.") .build() .generate_text() .await?; println!("Response text: {:?}", response.text()); Ok(()) } ``` ## Provider Settings You can customize provider configuration using `Zai::builder()` ### API Key ```rust let zai = Zai::::builder() .api_key("your-api-key") .build()?; ``` If not specified, AISDK uses the `ZHIPU_API_KEY` environment variable. ### Base URL Useful when routing through a proxy, gateway, or self-hosted compatible endpoint. ```rust let zai = Zai::::builder() .base_url("https://api.z.ai/api/paas/v4") .build()?; ``` ### Path (Full URL Override) Use `.path(...)` to override the full request URL instead of only the base URL. ```rust let zai = Zai::::builder() .path("https://full-url.example/v1/chat/completions") .build()?; ``` ### Provider Name For logging, analytics, and observability. ```rust let zai = Zai::::builder() .provider_name("Zai") .build()?; ``` ### Full Custom Configuration Example ```rust let zai = Zai::::builder() .api_key("your-api-key") .base_url("https://api.z.ai/api/paas/v4") .path("https://full-url.example/v1/chat/completions") .provider_name("Zai") .build()?; ``` ## Dynamic Model Selection For runtime model selection (e.g., loading models from config files), use `DynamicModel`: ### Using model\_name() Method with Default Settings ```rust use aisdk::providers::Zai; // Specify model as a string at runtime let zai = Zai::model_name("glm-4.5"); ``` ### Using Builder Pattern with Custom Settings ```rust use aisdk::{ core::DynamicModel, providers::Zai, }; let zai = Zai::::builder() .model_name("glm-4.5") .api_key("your-api-key") .base_url("https://api.z.ai/api/paas/v4") .path("https://full-url.example/v1/chat/completions") .provider_name("Zai") .build()?; ``` **Warning**: When using `DynamicModel`, model capabilities are **not validated at compile time**. This means there's no guarantee the model supports requested features (e.g., tool calls, structured output). For compile-time safety, use the typed methods like `Zai::glm_4_5()`. ## Next Steps * Take a deeper look at text generation features [Generating Text](/docs/concepts/generating-text#generate_text) / [Streaming Text](/docs/concepts/generating-text#stream_text) * Explore [Structured Output](/docs/concepts/structured-output) for reliable agent data. * Learn how to create [Custom Tools](/docs/concepts/tools). * Learn more about [Agents](/docs/concepts/agents). # Zenmux (/docs/providers/zenmux) AISDK provides first-class support for Zenmux with fully typed model APIs. Model capabilities are enforced at compile time using Rust's type system. This prevents model capability mismatches and guarantees the selected model is valid for the task (e.g. tool calling). ## Installation Enable the Zenmux provider feature: ```bash cargo add aisdk --features zenmux ``` This installs AISDK with the Zenmux provider enabled. Once you have enabled the Zenmux provider, you can use all aisdk features with it. ## Create a Provider Instance To create a provider instance, call `Zenmux::model_name()`, where **model\_name** is the Zenmux model you want to use. Model names are exposed as snake-case methods. ```rust use aisdk::providers::Zenmux; let zenmux = Zenmux::anthropic_claude_haiku_4_5(); ``` This initializes the provider with: * Model: `"anthropic/claude-haiku-4.5"` * API key from environment (if set with `ZENMUX_API_KEY`) * Zenmux's default base URL ([https://zenmux.ai/api/v1](https://zenmux.ai/api/v1)) ## Basic Text Generation Example using [LanguageModelRequest](https://docs.rs/aisdk/latest/aisdk/core/struct.LanguageModelRequest.html) for text generation. ```rust use aisdk::{ core::LanguageModelRequest, providers::Zenmux, }; #[tokio::main] async fn main() -> Result<(), Box> { let zenmux = Zenmux::anthropic_claude_haiku_4_5(); let response = LanguageModelRequest::builder() .model(zenmux) .prompt("Write a short poem about Rust.") .build() .generate_text() .await?; println!("Response text: {:?}", response.text()); Ok(()) } ``` ## Provider Settings You can customize provider configuration using `Zenmux::builder()` ### API Key ```rust let zenmux = Zenmux::::builder() .api_key("your-api-key") .build()?; ``` If not specified, AISDK uses the `ZENMUX_API_KEY` environment variable. ### Base URL Useful when routing through a proxy, gateway, or self-hosted compatible endpoint. ```rust let zenmux = Zenmux::::builder() .base_url("https://zenmux.ai/api/v1") .build()?; ``` ### Path (Full URL Override) Use `.path(...)` to override the full request URL instead of only the base URL. ```rust let zenmux = Zenmux::::builder() .path("https://full-url.example/v1/chat/completions") .build()?; ``` ### Provider Name For logging, analytics, and observability. ```rust let zenmux = Zenmux::::builder() .provider_name("Zenmux") .build()?; ``` ### Full Custom Configuration Example ```rust let zenmux = Zenmux::::builder() .api_key("your-api-key") .base_url("https://zenmux.ai/api/v1") .path("https://full-url.example/v1/chat/completions") .provider_name("Zenmux") .build()?; ``` ## Dynamic Model Selection For runtime model selection (e.g., loading models from config files), use `DynamicModel`: ### Using model\_name() Method with Default Settings ```rust use aisdk::providers::Zenmux; // Specify model as a string at runtime let zenmux = Zenmux::model_name("anthropic/claude-haiku-4.5"); ``` ### Using Builder Pattern with Custom Settings ```rust use aisdk::{ core::DynamicModel, providers::Zenmux, }; let zenmux = Zenmux::::builder() .model_name("anthropic/claude-haiku-4.5") .api_key("your-api-key") .base_url("https://zenmux.ai/api/v1") .path("https://full-url.example/v1/chat/completions") .provider_name("Zenmux") .build()?; ``` **Warning**: When using `DynamicModel`, model capabilities are **not validated at compile time**. This means there's no guarantee the model supports requested features (e.g., tool calls, structured output). For compile-time safety, use the typed methods like `Zenmux::anthropic_claude_haiku_4_5()`. ## Next Steps * Take a deeper look at text generation features [Generating Text](/docs/concepts/generating-text#generate_text) / [Streaming Text](/docs/concepts/generating-text#stream_text) * Explore [Structured Output](/docs/concepts/structured-output) for reliable agent data. * Learn how to create [Custom Tools](/docs/concepts/tools). * Learn more about [Agents](/docs/concepts/agents). # ZhipuaiCodingPlan (/docs/providers/zhipuai-coding-plan) AISDK provides first-class support for ZhipuaiCodingPlan with fully typed model APIs. Model capabilities are enforced at compile time using Rust's type system. This prevents model capability mismatches and guarantees the selected model is valid for the task (e.g. tool calling). ## Installation Enable the ZhipuaiCodingPlan provider feature: ```bash cargo add aisdk --features zhipuai-coding-plan ``` This installs AISDK with the ZhipuaiCodingPlan provider enabled. Once you have enabled the ZhipuaiCodingPlan provider, you can use all aisdk features with it. ## Create a Provider Instance To create a provider instance, call `ZhipuaiCodingPlan::model_name()`, where **model\_name** is the ZhipuaiCodingPlan model you want to use. Model names are exposed as snake-case methods. ```rust use aisdk::providers::ZhipuaiCodingPlan; let zhipuai-coding-plan = ZhipuaiCodingPlan::glm_4_5(); ``` This initializes the provider with: * Model: `"glm-4.5"` * API key from environment (if set with `ZHIPU_API_KEY`) * ZhipuaiCodingPlan's default base URL ([https://open.bigmodel.cn/api/coding/paas/v4](https://open.bigmodel.cn/api/coding/paas/v4)) ## Basic Text Generation Example using [LanguageModelRequest](https://docs.rs/aisdk/latest/aisdk/core/struct.LanguageModelRequest.html) for text generation. ```rust use aisdk::{ core::LanguageModelRequest, providers::ZhipuaiCodingPlan, }; #[tokio::main] async fn main() -> Result<(), Box> { let zhipuai-coding-plan = ZhipuaiCodingPlan::glm_4_5(); let response = LanguageModelRequest::builder() .model(zhipuai-coding-plan) .prompt("Write a short poem about Rust.") .build() .generate_text() .await?; println!("Response text: {:?}", response.text()); Ok(()) } ``` ## Provider Settings You can customize provider configuration using `ZhipuaiCodingPlan::builder()` ### API Key ```rust let zhipuai-coding-plan = ZhipuaiCodingPlan::::builder() .api_key("your-api-key") .build()?; ``` If not specified, AISDK uses the `ZHIPU_API_KEY` environment variable. ### Base URL Useful when routing through a proxy, gateway, or self-hosted compatible endpoint. ```rust let zhipuai-coding-plan = ZhipuaiCodingPlan::::builder() .base_url("https://open.bigmodel.cn/api/coding/paas/v4") .build()?; ``` ### Path (Full URL Override) Use `.path(...)` to override the full request URL instead of only the base URL. ```rust let zhipuai-coding-plan = ZhipuaiCodingPlan::::builder() .path("https://full-url.example/v1/chat/completions") .build()?; ``` ### Provider Name For logging, analytics, and observability. ```rust let zhipuai-coding-plan = ZhipuaiCodingPlan::::builder() .provider_name("ZhipuaiCodingPlan") .build()?; ``` ### Full Custom Configuration Example ```rust let zhipuai-coding-plan = ZhipuaiCodingPlan::::builder() .api_key("your-api-key") .base_url("https://open.bigmodel.cn/api/coding/paas/v4") .path("https://full-url.example/v1/chat/completions") .provider_name("ZhipuaiCodingPlan") .build()?; ``` ## Dynamic Model Selection For runtime model selection (e.g., loading models from config files), use `DynamicModel`: ### Using model\_name() Method with Default Settings ```rust use aisdk::providers::ZhipuaiCodingPlan; // Specify model as a string at runtime let zhipuai-coding-plan = ZhipuaiCodingPlan::model_name("glm-4.5"); ``` ### Using Builder Pattern with Custom Settings ```rust use aisdk::{ core::DynamicModel, providers::ZhipuaiCodingPlan, }; let zhipuai-coding-plan = ZhipuaiCodingPlan::::builder() .model_name("glm-4.5") .api_key("your-api-key") .base_url("https://open.bigmodel.cn/api/coding/paas/v4") .path("https://full-url.example/v1/chat/completions") .provider_name("ZhipuaiCodingPlan") .build()?; ``` **Warning**: When using `DynamicModel`, model capabilities are **not validated at compile time**. This means there's no guarantee the model supports requested features (e.g., tool calls, structured output). For compile-time safety, use the typed methods like `ZhipuaiCodingPlan::glm_4_5()`. ## Next Steps * Take a deeper look at text generation features [Generating Text](/docs/concepts/generating-text#generate_text) / [Streaming Text](/docs/concepts/generating-text#stream_text) * Explore [Structured Output](/docs/concepts/structured-output) for reliable agent data. * Learn how to create [Custom Tools](/docs/concepts/tools). * Learn more about [Agents](/docs/concepts/agents). # Zhipuai (/docs/providers/zhipuai) AISDK provides first-class support for Zhipuai with fully typed model APIs. Model capabilities are enforced at compile time using Rust's type system. This prevents model capability mismatches and guarantees the selected model is valid for the task (e.g. tool calling). ## Installation Enable the Zhipuai provider feature: ```bash cargo add aisdk --features zhipuai ``` This installs AISDK with the Zhipuai provider enabled. Once you have enabled the Zhipuai provider, you can use all aisdk features with it. ## Create a Provider Instance To create a provider instance, call `Zhipuai::model_name()`, where **model\_name** is the Zhipuai model you want to use. Model names are exposed as snake-case methods. ```rust use aisdk::providers::Zhipuai; let zhipuai = Zhipuai::glm_4_5(); ``` This initializes the provider with: * Model: `"glm-4.5"` * API key from environment (if set with `ZHIPU_API_KEY`) * Zhipuai's default base URL ([https://open.bigmodel.cn/api/paas/v4](https://open.bigmodel.cn/api/paas/v4)) ## Basic Text Generation Example using [LanguageModelRequest](https://docs.rs/aisdk/latest/aisdk/core/struct.LanguageModelRequest.html) for text generation. ```rust use aisdk::{ core::LanguageModelRequest, providers::Zhipuai, }; #[tokio::main] async fn main() -> Result<(), Box> { let zhipuai = Zhipuai::glm_4_5(); let response = LanguageModelRequest::builder() .model(zhipuai) .prompt("Write a short poem about Rust.") .build() .generate_text() .await?; println!("Response text: {:?}", response.text()); Ok(()) } ``` ## Provider Settings You can customize provider configuration using `Zhipuai::builder()` ### API Key ```rust let zhipuai = Zhipuai::::builder() .api_key("your-api-key") .build()?; ``` If not specified, AISDK uses the `ZHIPU_API_KEY` environment variable. ### Base URL Useful when routing through a proxy, gateway, or self-hosted compatible endpoint. ```rust let zhipuai = Zhipuai::::builder() .base_url("https://open.bigmodel.cn/api/paas/v4") .build()?; ``` ### Path (Full URL Override) Use `.path(...)` to override the full request URL instead of only the base URL. ```rust let zhipuai = Zhipuai::::builder() .path("https://full-url.example/v1/chat/completions") .build()?; ``` ### Provider Name For logging, analytics, and observability. ```rust let zhipuai = Zhipuai::::builder() .provider_name("Zhipuai") .build()?; ``` ### Full Custom Configuration Example ```rust let zhipuai = Zhipuai::::builder() .api_key("your-api-key") .base_url("https://open.bigmodel.cn/api/paas/v4") .path("https://full-url.example/v1/chat/completions") .provider_name("Zhipuai") .build()?; ``` ## Dynamic Model Selection For runtime model selection (e.g., loading models from config files), use `DynamicModel`: ### Using model\_name() Method with Default Settings ```rust use aisdk::providers::Zhipuai; // Specify model as a string at runtime let zhipuai = Zhipuai::model_name("glm-4.5"); ``` ### Using Builder Pattern with Custom Settings ```rust use aisdk::{ core::DynamicModel, providers::Zhipuai, }; let zhipuai = Zhipuai::::builder() .model_name("glm-4.5") .api_key("your-api-key") .base_url("https://open.bigmodel.cn/api/paas/v4") .path("https://full-url.example/v1/chat/completions") .provider_name("Zhipuai") .build()?; ``` **Warning**: When using `DynamicModel`, model capabilities are **not validated at compile time**. This means there's no guarantee the model supports requested features (e.g., tool calls, structured output). For compile-time safety, use the typed methods like `Zhipuai::glm_4_5()`. ## Next Steps * Take a deeper look at text generation features [Generating Text](/docs/concepts/generating-text#generate_text) / [Streaming Text](/docs/concepts/generating-text#stream_text) * Explore [Structured Output](/docs/concepts/structured-output) for reliable agent data. * Learn how to create [Custom Tools](/docs/concepts/tools). * Learn more about [Agents](/docs/concepts/agents).