AI-Protocol is a provider-agnostic specification for all AI models, standardizing how we interact with intelligence, regardless of modality (text, vision, audio, video). We decouple the "data-state rulebook" from the "language-state runtime" to provide unified infrastructure for the AI ecosystem.
We complement standards like MCP by providing a declarative runtime for raw API normalization. While MCP focuses on high-level protocols for tool calling and context management, AI-Protocol focuses on standardizing and normalizing low-level API calls, enabling runtimes to uniformly handle APIs from different providers.
- Data-State Rulebook: Focuses on defining standardized interfaces and behavioral norms for AI models
- Language-State Runtime: Focuses on implementing efficient, scalable AI model runtimes (like ai-lib)
- Ecosystem Decoupling: Protocol specifications are separated from implementations, supporting unified ecosystems across multiple languages and frameworks
- Provider-Agnostic: Unifies APIs from different AI providers, enabling true cross-provider interoperability
- Cross-Modality Support: Standardizes interactions across text, vision, audio, video, and other modalities
ai-protocol/
βββ schemas/ # JSON Schema validation specifications
β βββ v1.json # v1.x stable version Schema
βββ v1/ # v1.x stable version specification
β βββ spec.yaml # Basic specifications: standard parameters, event enumeration
β βββ providers/ # Provider configurations (split by vendor for easy PR)
β β βββ openai.yaml # OpenAI compatible interface
β β βββ anthropic.yaml # Anthropic Claude interface
β β βββ gemini.yaml # Google Gemini interface
β β βββ groq.yaml # Groq compatible interface
β β βββ deepseek.yaml # DeepSeek compatible interface
β β βββ qwen.yaml # Qwen (DashScope) compatible interface
β β βββ ... # More providers
β βββ models/ # Model instance registry
β βββ gpt.yaml # GPT series models
β βββ claude.yaml # Claude series models
β βββ ... # More models
βββ v2-alpha/ # v2-alpha experimental version: multimodal and real-time features
β βββ spec.yaml # Experimental operator definitions
β βββ providers/ # Experimental provider configurations
βββ examples/ # Configuration examples
β βββ tool_accumulation.yaml # Tool accumulation pattern example
βββ research/ # Research documents (official API excerpts and verification)
β βββ providers/ # Provider-specific official documentation research
β βββ openai.md # OpenAI official API rules (VERIFIED)
β βββ anthropic.md # Anthropic official API rules (VERIFIED)
β βββ gemini.md # Gemini official API rules (VERIFIED)
β βββ ... # More provider research
βββ scripts/ # Maintenance scripts
To avoid publishing work/discussion/internal documents by default, release archives SHOULD exclude:
research/scripts/v2-alpha/
The normative, publish-ready artifacts are:
schemas/v1/(spec + providers + models)examples/README.md,LICENSE-*,CHANGELOG.md
AI-Protocol standardizes AI model behavior through the concept of operators:
- Parameter Operators: Standardized parameter mapping (
temperature,max_tokens,stream, etc.) - Event Operators: Standardized streaming events (
PartialContentDelta,ToolCallStarted,StreamError, etc.) - Capability Operators: Standardized capability declarations (
chat,vision,tools,streaming,multimodal, etc.) - Error Handling Operators: Standardized error classification, rate limiting, and retry strategies (
error_classification,retry_policy,rate_limit_headers)
- v1.x: Production environment stable version, supporting current mainstream AI models
- v2-alpha: Experimental version, exploring multimodal streams, real-time instructions, and other cutting-edge features
- Schema Constraints: Every configuration file is strictly validated through JSON Schema
- Provider Independence: Each AI provider's configuration is maintained independently, facilitating community contributions
- Model Registration: Model instances are registered as configuration files referencing provider definitions
- PR Friendly: Modifying a single provider won't affect other configurations
# v1/providers/anthropic.yaml
$schema: "https://github.com/hiddenpath/ai-protocol/tree/main/schemas/v1.json"
id: anthropic
protocol_version: "1.1"
streaming:
decoder:
format: "sse"
strategy: "anthropic_event_stream"
event_map:
- match: { "path": "$.type", "op": "eq", "value": "content_block_delta" }
emit: "PartialContentDelta"
extract:
content: "$.delta.text"# v1/providers/openai.yaml (excerpt)
error_classification:
by_http_status:
"400": "invalid_request"
"401": "authentication"
"429": "rate_limited" # Could be rate limit or quota exhausted
"500": "server_error"
rate_limit_headers:
requests_limit: "x-ratelimit-limit-requests"
requests_remaining: "x-ratelimit-remaining-requests"
retry_after: null # OpenAI doesn't use standard Retry-After
retry_policy:
strategy: "exponential_backoff"
min_delay_ms: 1000
jitter: "full"
retry_on_http_status: [429, 500]
notes:
- "429 may be rate limit or quota exhausted; runtimes should inspect error messages"# v1/models/claude.yaml
$schema: "https://github.com/hiddenpath/ai-protocol/tree/main/schemas/v1.json"
models:
claude-3-5-sonnet:
provider: anthropic
model_id: "claude-3-5-sonnet-20241022"
context_window: 200000
capabilities: [chat, vision, tools, streaming, agentic, reasoning]
pricing:
input_per_token: 0.000003
output_per_token: 0.000015// Dynamic loading example in ai-lib
use ai_protocol::{ProtocolRegistry, ProviderConfig};
let registry = ProtocolRegistry::new();
let provider = registry.load_provider("anthropic").await?;
let model = registry.get_model("claude-3-5-sonnet").await?;# Run JSON Schema validation
npm install -g ajv-cli
ajv validate -s schemas/v1.json -d "v1/providers/*.yaml"
# Run compatibility tests
cargo test --package ai-protocol-validationValidation scripts are also available in scripts/validate-configs.sh.
- β Mainstream AI provider support (OpenAI, Anthropic, Gemini, Groq, DeepSeek, Qwen)
- β Standardized parameters and event normalization
- β Tool calling and streaming response support
- β JSON Schema constraints
- β
Error handling and classification standardization (
error_classification, 13 standard error classes) - β
Rate limiting and retry policy standardization (
rate_limit_headers,retry_policy) - β
API family declarations (
api_families,endpoints) to avoid request/response model confusion - β
Termination reason normalization (
termination_reasons) unified across providers
- π Multimodal stream interleaving (
FrameInterleaveoperator) - π Real-time instructions (
StateSyncoperator) - π Schema-less mapping (Schema-less Mapping)
- π Advanced tool accumulation patterns
- π Audio/video streaming processing
- π Real-time collaborative sessions
- π Model switching and migration
- π Performance monitoring and QoS
- Create a new file under
v1/providers/(e.g.,new-provider.yaml) - Follow JSON Schema specifications (
schemas/v1.json) - Add official documentation research under
research/providers/(new-provider.md) with VERIFIED evidence - Add corresponding model configurations under
v1/models/ - Submit PR with test cases and validation results
All configurations are hosted in this repository, where community contributions follow the same version control and validation process as official configurations.
- Define new operators in the corresponding version's
spec.yaml - Update JSON Schema
- Implement operator logic in runtime
- Add example configurations
This project is licensed under either of
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT License (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you shall be dual licensed as above, without any additional terms or conditions.
- ai-lib: Rust runtime implementation
- ai-lib-python: Python runtime implementation (planned)
Note: AI-Protocol itself already includes configuration registry functionality. Community contributions for new provider configurations and model registrations can be submitted directly via PRs to this repository's
v1/providers/andv1/models/directories, without needing a separate configuration repository.
AI-Protocol abstracts the complexity of AI models into standardized protocols, allowing developers to focus on business logic rather than provider adaptation.