AI-Lib
Specification v0.7.0 · 37 Providers · V2 Protocol

The Specification
That Drives Everything.

AI-Protocol separates "what to do" from "how to do it." The V2 specification uses a three-layer pyramid with three-ring manifests. New in v0.7.0: MCP tool integration schema, Computer Use abstraction with safety policies, extended multimodal (audio/video/omni), ProviderContract, and a CLI validation tool.

V2 Three-Layer Architecture

V2 organizes the specification into three layers: L1 Core Protocol (message format, error codes) → L2 Capability Extensions (streaming, tools, MCP, Computer Use, multimodal) → L3 Environment Profile (API keys, endpoints, retry). 6 V2 manifests available: OpenAI, Anthropic, Gemini, DeepSeek, Moonshot, Zhipu.

What's Inside

spec.yaml

Core Specification

Defines standard parameters (temperature, max_tokens), streaming events (PartialContentDelta, ToolCallStarted), error classes (13 types), and retry policies.

providers/

37 Provider Manifests

36 V1 + 6 V2 manifests. V2 manifests use three-ring structure with MCP, Computer Use, and multimodal capability declarations.

models/

Model Registry

Model instances with provider references, context windows, capability flags, and per-token pricing. GPT, Claude, Gemini, DeepSeek, Qwen, and more.

schemas/

V2 Schema Suite

6 JSON Schemas: provider, ProviderContract, MCP, Computer Use, multimodal, context policy. CI validation ensures correctness.

A Provider Manifest

Each provider is described by a YAML manifest. It declares everything a runtime needs to communicate with the provider — endpoint, authentication, parameter mapping, streaming decoder, error handling, and capabilities.

Runtimes read these manifests and "compile" user requests into provider-specific HTTP calls. No if provider == "openai" branches anywhere.

  • Endpoint & Auth — Base URL, protocol, bearer tokens, API key headers
  • Parameter Mapping — Standard names to provider-specific JSON fields
  • Streaming Decoder — SSE/NDJSON format, JSONPath event extraction rules
  • Error Classification — HTTP status codes to 13 standard error types
id: anthropic
protocol_version: "0.7.0"
endpoint:
  base_url: "https://api.anthropic.com/v1"
  chat_path: "/messages"
auth:
  type: bearer
  token_env: "ANTHROPIC_API_KEY"
parameter_mappings:
  temperature: "temperature"
  max_tokens: "max_tokens"
  stream: "stream"
streaming:
  decoder:
    format: "anthropic_sse"
  event_map:
    - match: "$.type == 'content_block_delta'"
      emit: "PartialContentDelta"
error_classification:
  by_http_status:
    "429": "rate_limited"
    "401": "authentication"
capabilities:
  streaming: true
  tools: true
  vision: true

Where Protocol Fits

AI-Protocol is the foundation layer. Runtimes consume it. Applications consume runtimes.

AI-Lib Ecosystem Architecture APPLICATION RUNTIME PROTOCOL Web Apps / API Services Rust / Python / TS Your application code AI Agents Multi-turn / Tool Calling CLI Tools Batch / Data Pipelines Testing & Dev Mock Services ai-lib-rust v0.8.5 AiClient Pipeline Transport Resilience Embeddings Cache / Batch Crates.io · tokio + reqwest · <1ms overhead ai-lib-python v0.7.4 AiClient Pipeline Transport Resilience Telemetry Routing PyPI · httpx + Pydantic v2 · async/await ai-lib-ts v0.4.0 AiClient Pipeline Transport Resilience MCP Bridge Batch NPM · fetch + Zod · ESM / CJS Load Manifests AI-Protocol v0.7.6 spec.yaml Core Specification providers/*.yaml 37 Provider Manifests models/*.yaml Model Registry YAML definitions → JSON compilation → Runtime consumption · Vendor neutral ai-protocol-mock v0.1.7 Mock Server Local Testing Record/Replay Snapshot Tests Protocol Compliance Check Dev Testing · CI/CD · No real API needed mock

Supported Providers

Each provider has a complete YAML manifest with endpoint, auth, parameter mappings, streaming decoder, error handling, and capability flags.

OpenAI
Anthropic
Google Gemini
Groq
Mistral
DeepSeek
Qwen
Cohere
Azure OpenAI
Together AI
Perplexity
NVIDIA
Fireworks AI
Replicate
OpenRouter
DeepInfra
AI21 Labs
Cerebras
Lepton AI
Zhipu GLM
Doubao
Baidu ERNIE
Tencent Hunyuan
iFlytek Spark
Moonshot
MiniMax
Baichuan
Yi / 01.AI
SiliconFlow
SenseNova

Explore the Protocol

Read the specification, browse provider manifests, or contribute a new provider.