Skip to main content

Quickstart

This guide will get you from zero to making your first AI model call in under 5 minutes.

Prerequisites

1

Paid t3.chat Account

You need an active paid subscription to t3.chat. Free accounts are not supported.If you don’t have one, visit t3.chat to subscribe.
2

Rust Toolchain

Make sure you have Rust installed. If not, install it from rustup.rs:
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

Installation

1

Add Dependencies

Add T3Router to your Cargo.toml:
Cargo.toml
[dependencies]
t3router = { git = "https://github.com/vibheksoni/t3router" }
tokio = { version = "1.47", features = ["full"] }
dotenv = "0.15"
The library requires tokio for async runtime and dotenv for environment variable management.
2

Get Your Credentials

You need two pieces of information from your t3.chat session:
  1. Open t3.chat in your browser
  2. Press F12 to open Developer Tools
  3. Go to the Application tab (Chrome) or Storage tab (Firefox)
  4. Click on Cookieshttps://t3.chat
  5. Copy the entire cookie string (see Authentication for detailed instructions)
  6. Find and copy the value of convex-session-id
Keep these credentials private. Never commit them to version control.
3

Configure Environment

Create a .env file in your project root:
.env
COOKIES="your_full_cookie_string_here"
CONVEX_SESSION_ID="your_session_id_here"
Add .env to your .gitignore:
.gitignore
.env

Your First Request

Create src/main.rs with this complete working example:
src/main.rs
use t3router::t3::{
    client::Client,
    message::{Message, Type},
    config::Config
};
use dotenv::dotenv;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    // Load environment variables from .env file
    dotenv().ok();
    
    // Get credentials from environment
    let cookies = std::env::var("COOKIES")?;
    let session_id = format!("\"{}\"", std::env::var("CONVEX_SESSION_ID")?);
    
    // Create and initialize the client
    let mut client = Client::new(cookies, session_id);
    client.init().await?;
    
    println!("Client initialized successfully\n");
    
    // Create default configuration
    let config = Config::new();
    
    // Send a message to Claude
    println!("Sending message to claude-3.7...");
    let response = client.send(
        "claude-3.7",
        Some(Message::new(
            Type::User,
            "Explain what Rust's ownership system is in one sentence.".to_string()
        )),
        Some(config)
    ).await?;
    
    println!("\nAssistant: {}", response.content);
    println!("\nMessage ID: {}", response.id);
    println!("Total messages in conversation: {}", client.get_messages().len());
    
    Ok(())
}

Run Your Code

Execute your program:
cargo run

Expected Output

Client initialized successfully

Sending message to claude-3.7...

Assistant: Rust's ownership system enforces memory safety at compile time by ensuring each value has a single owner and is automatically cleaned up when the owner goes out of scope, preventing common bugs like use-after-free and data races without needing a garbage collector.

Message ID: 3f8a9c2e-5b1d-4f7e-9a3c-8d2e6f4b1a9c
Total messages in conversation: 2

Try Different Models

T3Router supports 50+ models. Try switching to a different one:
let response = client.send(
    "gpt-4o",
    Some(Message::new(Type::User, "Hello!".to_string())),
    Some(config)
).await?;

Common Issues

Make sure your .env file exists in your project root and contains the COOKIES variable.Run dotenv().ok(); at the start of your main() function.
Your cookies may have expired. Go back to t3.chat in your browser and extract fresh credentials.
Check that:
  1. Your t3.chat subscription is active
  2. You’re using a valid model name
  3. The convex-session-id is properly formatted with quotes: format!("\"{}\"\, session_id)

Next Steps

Authentication Guide

Learn the detailed process for extracting and managing your credentials.

API Reference

Explore all available methods, types, and configuration options.
Pro tip: The Client automatically manages conversation threads. Each message you send is added to the conversation history, allowing for multi-turn interactions.

Build docs developers (and LLMs) love