ai-connect

Crates.ioai-connect
lib.rsai-connect
version0.1.0
created_at2026-01-11 19:01:57.682498+00
updated_at2026-01-11 19:01:57.682498+00
descriptionConnect to AI provider accounts via OAuth 2.0 + PKCE. Supports Anthropic, OpenAI, and custom providers.
homepage
repositoryhttps://github.com/ooojustin/ai-connect
max_upload_size
id2036235
size105,828
justin (ooojustin)

documentation

README

ai-connect

A Rust library for authenticating with AI provider subscriptions using OAuth 2.0 + PKCE.

Supported Providers

  • Anthropic (Claude Code)
  • OpenAI (Codex)

Installation

[dependencies]
ai-connect = { version = "0.1", features = ["local-server"] }

Usage

Code:

use ai_connect::{AnthropicProvider, OAuthError};

#[tokio::main]
async fn main() -> Result<(), OAuthError> {
    let auth = AnthropicProvider::authorize(|req| {
        println!("Authorization URL: {}", req.url);
        Ok(())
    })?;

    let response = auth.wait().await?;
    println!("{}", serde_json::to_string_pretty(&response)?);
    Ok(())
}

Output:

{
  "access_token": "[REDACTED]",
  "refresh_token": "[REDACTED]",
  "token_type": "Bearer",
  "scope": "user:inference user:profile",
  "expires_in": 28800,
  "organization": {
    "name": "My Organization",
    "uuid": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
  },
  "account": {
    "email_address": "my@email.net",
    "uuid": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
  }
}
Commit count: 10

cargo fmt