Skip to main content

Crate mixtape_core

Crate mixtape_core 

Source
Expand description

§Mixtape

A Rust SDK for building AI agents with tool use, streaming, and multi-provider support.

Mixtape provides a high-level API for creating conversational AI agents that can use tools, stream responses, and work with multiple LLM providers (AWS Bedrock, Anthropic API).

§Quick Start

use mixtape_core::{Agent, ClaudeSonnet4_5};

#[tokio::main]
async fn main() -> mixtape_core::Result<()> {
    // Create an agent with Bedrock provider
    let agent = Agent::builder()
        .bedrock(ClaudeSonnet4_5)
        .with_system_prompt("You are a helpful assistant.")
        .build()
        .await?;

    // Run a conversation
    let response = agent.run("What is 2 + 2?").await?;
    println!("{}", response);

    Ok(())
}

§Features

  • Multiple Providers: Support for AWS Bedrock and Anthropic API
  • Tool Use: Define custom tools with automatic JSON schema generation
  • Streaming: Real-time response streaming with event hooks
  • Session Management: Persist conversations across runs (optional)
  • MCP Support: Connect to Model Context Protocol servers (optional)
  • Extended Thinking: Enable Claude’s reasoning capabilities

§Creating Agents

Use the builder pattern to create agents:

use mixtape_core::{Agent, ClaudeSonnet4_5};

// Using AWS Bedrock
let agent = Agent::builder()
    .bedrock(ClaudeSonnet4_5)
    .build()
    .await?;

// Using Anthropic API directly
let agent = Agent::builder()
    .anthropic(ClaudeSonnet4_5, "sk-ant-api-key")
    .build()
    .await?;

§Adding Tools

Implement the Tool trait to create custom tools:

use mixtape_core::{Tool, ToolError, ToolResult};
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};

#[derive(Debug, Deserialize, Serialize, JsonSchema)]
struct CalculatorInput {
    expression: String,
}

struct Calculator;

impl Tool for Calculator {
    type Input = CalculatorInput;

    fn name(&self) -> &str { "calculator" }
    fn description(&self) -> &str { "Evaluate a math expression" }

    async fn execute(&self, input: Self::Input) -> Result<ToolResult, ToolError> {
        // Parse and evaluate the expression
        Ok(ToolResult::text("42"))
    }
}

Add tools to an agent with add_tool() or add_tools():

use mixtape_core::{Agent, box_tools, ClaudeSonnet4};

// Single tool
let agent = Agent::builder()
    .bedrock(ClaudeSonnet4)
    .add_tool(Calculator)
    .build()
    .await?;

// Multiple heterogeneous tools with the box_tools! macro
let agent = Agent::builder()
    .bedrock(ClaudeSonnet4)
    .add_tools(box_tools![Calculator, WeatherLookup, FileReader])
    .build()
    .await?;

// Tool groups from mixtape-tools
use mixtape_tools::sqlite;

let agent = Agent::builder()
    .bedrock(ClaudeSonnet4)
    .add_tools(sqlite::read_only_tools())
    .build()
    .await?;

§Feature Flags

  • bedrock - AWS Bedrock provider support (enabled by default)
  • anthropic - Anthropic API provider support
  • session - Session persistence for multi-turn conversations
  • mcp - Model Context Protocol server integration

Re-exports§

pub use agent::Agent;
pub use agent::AgentBuilder;
pub use agent::AgentError;
pub use agent::AgentResponse;
pub use agent::ContextConfig;
pub use agent::ContextError;
pub use agent::ContextLoadResult;
pub use agent::ContextSource;
pub use agent::PermissionError;
pub use agent::TokenUsageStats;
pub use agent::ToolCallInfo;
pub use agent::ToolInfo;
pub use agent::DEFAULT_MAX_CONCURRENT_TOOLS;
pub use agent::DEFAULT_PERMISSION_TIMEOUT;
pub use conversation::BoxedConversationManager;
pub use conversation::ContextLimits;
pub use conversation::ContextUsage;
pub use conversation::ConversationManager;
pub use conversation::NoOpConversationManager;
pub use conversation::SimpleConversationManager;
pub use conversation::SlidingWindowConversationManager;
pub use conversation::TokenEstimator;
pub use error::Error;
pub use error::Result;
pub use events::AgentEvent;
pub use events::AgentHook;
pub use events::HookId;
pub use events::TokenUsage;
pub use model::AnthropicModel;
pub use model::BedrockModel;
pub use model::InferenceProfile;
pub use model::Model;
pub use model::ModelRequest;
pub use model::ModelResponse;
pub use permission::hash_params;
pub use permission::Authorization;
pub use permission::AuthorizationResponse;
pub use permission::FileGrantStore;
pub use permission::Grant;
pub use permission::GrantStore;
pub use permission::GrantStoreError;
pub use permission::MemoryGrantStore;
pub use permission::Scope;
pub use permission::ToolAuthorizationPolicy;
pub use permission::ToolCallAuthorizer;
pub use presentation::Display;
pub use provider::ModelProvider;
pub use provider::ProviderError;
pub use provider::RetryConfig;
pub use provider::RetryInfo;
pub use provider::StreamEvent;
pub use models::Claude3_7Sonnet;
pub use models::ClaudeHaiku4_5;
pub use models::ClaudeOpus4;
pub use models::ClaudeOpus4_1;
pub use models::ClaudeOpus4_5;
pub use models::ClaudeOpus4_6;
pub use models::ClaudeSonnet4;
pub use models::ClaudeSonnet4_5;
pub use models::Nova2Lite;
pub use models::Nova2Sonic;
pub use models::NovaLite;
pub use models::NovaMicro;
pub use models::NovaPremier;
pub use models::NovaPro;
pub use models::CohereCommandRPlus;
pub use models::DeepSeekR1;
pub use models::DeepSeekV3_1;
pub use models::DeepSeekV3_2;
pub use models::Gemma3_12B;
pub use models::Gemma3_27B;
pub use models::Gemma3_4B;
pub use models::Llama3_1_405B;
pub use models::Llama3_1_70B;
pub use models::Llama3_1_8B;
pub use models::Llama3_2_11B;
pub use models::Llama3_2_1B;
pub use models::Llama3_2_3B;
pub use models::Llama3_2_90B;
pub use models::Llama3_3_70B;
pub use models::Llama4Maverick17B;
pub use models::Llama4Scout17B;
pub use models::MagistralSmall;
pub use models::Ministral14B;
pub use models::Ministral3B;
pub use models::Ministral8B;
pub use models::MistralLarge3;
pub use models::PixtralLarge;
pub use models::VoxtralMini3B;
pub use models::VoxtralSmall24B;
pub use models::KimiK2Thinking;
pub use models::KimiK2_5;
pub use models::Qwen3Coder30B;
pub use models::Qwen3Coder480B;
pub use models::Qwen3Next80B;
pub use models::Qwen3VL235B;
pub use models::Qwen3_235B;
pub use models::Qwen3_32B;
pub use tokenizer::CharacterTokenizer;
pub use tool::box_tool;
pub use tool::DocumentFormat;
pub use tool::DynTool;
pub use tool::ImageFormat;
pub use tool::Tool;
pub use tool::ToolError;
pub use tool::ToolResult;
pub use types::ContentBlock;
pub use types::Message;
pub use types::Role;
pub use types::StopReason;
pub use types::ThinkingConfig;
pub use types::ToolDefinition;
pub use types::ToolResultBlock;
pub use types::ToolResultStatus;
pub use types::ToolUseBlock;

Modules§

agent
Agent module for orchestrating LLM interactions with tools
conversation
Conversation management for context window handling
error
Top-level error types for mixtape
events
model
Model traits and types
models
Pre-configured model definitions
permission
Permission system for tool execution.
presentation
provider
Model providers for LLM interactions
tokenizer
Token estimation utilities
tool
types
Provider-agnostic types for messages and tools

Macros§

box_tools
Create a Vec<Box<dyn DynTool>> from heterogeneous tool types.