@ailib-official/ai-protocol 0.8.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +6 -0
- package/README.md +415 -0
- package/dist/index.json +8 -0
- package/dist/v1/models/ai21.json +140 -0
- package/dist/v1/models/baichuan.json +138 -0
- package/dist/v1/models/cerebras.json +147 -0
- package/dist/v1/models/claude.json +114 -0
- package/dist/v1/models/cohere.json +235 -0
- package/dist/v1/models/deepinfra.json +43 -0
- package/dist/v1/models/deepseek-chat.json +55 -0
- package/dist/v1/models/doubao.json +197 -0
- package/dist/v1/models/ernie.json +223 -0
- package/dist/v1/models/fireworks.json +222 -0
- package/dist/v1/models/gemini.json +58 -0
- package/dist/v1/models/gpt.json +166 -0
- package/dist/v1/models/grok.json +138 -0
- package/dist/v1/models/huggingface.json +183 -0
- package/dist/v1/models/hunyuan.json +255 -0
- package/dist/v1/models/jina.json +139 -0
- package/dist/v1/models/lepton.json +188 -0
- package/dist/v1/models/llama.json +143 -0
- package/dist/v1/models/minimax.json +194 -0
- package/dist/v1/models/mistral.json +177 -0
- package/dist/v1/models/moonshot.json +144 -0
- package/dist/v1/models/nvidia.json +212 -0
- package/dist/v1/models/palmyra.json +103 -0
- package/dist/v1/models/perplexity.json +143 -0
- package/dist/v1/models/qwen.json +49 -0
- package/dist/v1/models/replicate.json +206 -0
- package/dist/v1/models/sensenova.json +144 -0
- package/dist/v1/models/siliconflow.json +44 -0
- package/dist/v1/models/spark.json +173 -0
- package/dist/v1/models/stable-diffusion.json +161 -0
- package/dist/v1/models/tiangong.json +169 -0
- package/dist/v1/models/together.json +43 -0
- package/dist/v1/models/yi.json +199 -0
- package/dist/v1/models/zhipu.json +250 -0
- package/dist/v1/providers/ai21.json +215 -0
- package/dist/v1/providers/anthropic.json +253 -0
- package/dist/v1/providers/anyscale.json +115 -0
- package/dist/v1/providers/azure.json +188 -0
- package/dist/v1/providers/baichuan.json +205 -0
- package/dist/v1/providers/baidu.json +205 -0
- package/dist/v1/providers/cerebras.json +216 -0
- package/dist/v1/providers/cohere.json +209 -0
- package/dist/v1/providers/deepinfra.json +196 -0
- package/dist/v1/providers/deepseek.json +221 -0
- package/dist/v1/providers/doubao.json +209 -0
- package/dist/v1/providers/fireworks.json +227 -0
- package/dist/v1/providers/gemini.json +279 -0
- package/dist/v1/providers/groq.json +218 -0
- package/dist/v1/providers/huggingface.json +181 -0
- package/dist/v1/providers/hunyuan.json +198 -0
- package/dist/v1/providers/jina.json +202 -0
- package/dist/v1/providers/lepton.json +221 -0
- package/dist/v1/providers/minimax.json +209 -0
- package/dist/v1/providers/mistral.json +214 -0
- package/dist/v1/providers/moonshot.json +214 -0
- package/dist/v1/providers/nvidia.json +213 -0
- package/dist/v1/providers/openai.json +267 -0
- package/dist/v1/providers/openrouter.json +220 -0
- package/dist/v1/providers/perplexity.json +172 -0
- package/dist/v1/providers/qwen.json +231 -0
- package/dist/v1/providers/replicate.json +192 -0
- package/dist/v1/providers/sensenova.json +185 -0
- package/dist/v1/providers/siliconflow.json +197 -0
- package/dist/v1/providers/spark.json +204 -0
- package/dist/v1/providers/stability.json +221 -0
- package/dist/v1/providers/tiangong.json +207 -0
- package/dist/v1/providers/together.json +196 -0
- package/dist/v1/providers/writer.json +253 -0
- package/dist/v1/providers/xai.json +238 -0
- package/dist/v1/providers/yi.json +205 -0
- package/dist/v1/providers/zhipu.json +208 -0
- package/dist/v1/spec.json +783 -0
- package/dist/v2/providers/anthropic.json +372 -0
- package/dist/v2/providers/cohere.json +109 -0
- package/dist/v2/providers/deepseek.json +272 -0
- package/dist/v2/providers/doubao.json +260 -0
- package/dist/v2/providers/google.json +388 -0
- package/dist/v2/providers/jina.json +71 -0
- package/dist/v2/providers/moonshot.json +284 -0
- package/dist/v2/providers/openai.json +419 -0
- package/dist/v2/providers/qwen.json +274 -0
- package/dist/v2/providers/zhipu.json +257 -0
- package/dist/v2-alpha/providers/anthropic.json +182 -0
- package/dist/v2-alpha/providers/gemini.json +187 -0
- package/dist/v2-alpha/providers/openai.json +215 -0
- package/dist/v2-alpha/spec.json +644 -0
- package/package.json +61 -0
- package/schemas/spec.json +186 -0
- package/schemas/v1.json +1116 -0
- package/schemas/v2/availability.json +66 -0
- package/schemas/v2/capabilities.json +182 -0
- package/schemas/v2/capability-profile.json +174 -0
- package/schemas/v2/computer-use.json +222 -0
- package/schemas/v2/context-policy.json +148 -0
- package/schemas/v2/endpoint.json +2 -0
- package/schemas/v2/error-codes.yaml +225 -0
- package/schemas/v2/errors.json +250 -0
- package/schemas/v2/execution-metadata.json +59 -0
- package/schemas/v2/mcp.json +225 -0
- package/schemas/v2/message-roles.json +10 -0
- package/schemas/v2/multimodal.json +297 -0
- package/schemas/v2/pricing.json +14 -0
- package/schemas/v2/provider-contract.json +317 -0
- package/schemas/v2/provider.json +203 -0
- package/schemas/v2/regions.json +14 -0
- package/v1/models/ai21.yaml +97 -0
- package/v1/models/baichuan.yaml +95 -0
- package/v1/models/cerebras.yaml +99 -0
- package/v1/models/claude.yaml +59 -0
- package/v1/models/cohere.yaml +165 -0
- package/v1/models/deepinfra.yaml +29 -0
- package/v1/models/deepseek-chat.yaml +32 -0
- package/v1/models/doubao.yaml +129 -0
- package/v1/models/ernie.yaml +146 -0
- package/v1/models/fireworks.yaml +145 -0
- package/v1/models/gemini.yaml +32 -0
- package/v1/models/gpt.yaml +90 -0
- package/v1/models/grok.yaml +74 -0
- package/v1/models/huggingface.yaml +110 -0
- package/v1/models/hunyuan.yaml +164 -0
- package/v1/models/jina.yaml +98 -0
- package/v1/models/lepton.yaml +130 -0
- package/v1/models/llama.yaml +91 -0
- package/v1/models/minimax.yaml +132 -0
- package/v1/models/mistral.yaml +100 -0
- package/v1/models/moonshot.yaml +97 -0
- package/v1/models/nvidia.yaml +118 -0
- package/v1/models/palmyra.yaml +59 -0
- package/v1/models/perplexity.yaml +97 -0
- package/v1/models/qwen.yaml +27 -0
- package/v1/models/replicate.yaml +136 -0
- package/v1/models/sensenova.yaml +97 -0
- package/v1/models/siliconflow.yaml +29 -0
- package/v1/models/spark.yaml +114 -0
- package/v1/models/stable-diffusion.yaml +113 -0
- package/v1/models/tiangong.yaml +114 -0
- package/v1/models/together.yaml +29 -0
- package/v1/models/yi.yaml +132 -0
- package/v1/models/zhipu.yaml +163 -0
- package/v1/providers/ai21.yaml +176 -0
- package/v1/providers/anthropic.yaml +209 -0
- package/v1/providers/anyscale.yaml +106 -0
- package/v1/providers/azure.yaml +155 -0
- package/v1/providers/baichuan.yaml +168 -0
- package/v1/providers/baidu.yaml +173 -0
- package/v1/providers/cerebras.yaml +178 -0
- package/v1/providers/cohere.yaml +175 -0
- package/v1/providers/deepinfra.yaml +156 -0
- package/v1/providers/deepseek.yaml +189 -0
- package/v1/providers/doubao.yaml +172 -0
- package/v1/providers/fireworks.yaml +187 -0
- package/v1/providers/gemini.yaml +229 -0
- package/v1/providers/groq.yaml +181 -0
- package/v1/providers/huggingface.yaml +157 -0
- package/v1/providers/hunyuan.yaml +162 -0
- package/v1/providers/jina.yaml +171 -0
- package/v1/providers/lepton.yaml +183 -0
- package/v1/providers/minimax.yaml +172 -0
- package/v1/providers/mistral.yaml +186 -0
- package/v1/providers/moonshot.yaml +176 -0
- package/v1/providers/nvidia.yaml +172 -0
- package/v1/providers/openai.yaml +224 -0
- package/v1/providers/openrouter.yaml +181 -0
- package/v1/providers/perplexity.yaml +144 -0
- package/v1/providers/qwen.yaml +192 -0
- package/v1/providers/replicate.yaml +159 -0
- package/v1/providers/sensenova.yaml +153 -0
- package/v1/providers/siliconflow.yaml +156 -0
- package/v1/providers/spark.yaml +167 -0
- package/v1/providers/stability.yaml +185 -0
- package/v1/providers/tiangong.yaml +170 -0
- package/v1/providers/together.yaml +156 -0
- package/v1/providers/writer.yaml +212 -0
- package/v1/providers/xai.yaml +206 -0
- package/v1/providers/yi.yaml +168 -0
- package/v1/providers/zhipu.yaml +171 -0
- package/v1/spec.yaml +637 -0
- package/v2/providers/anthropic.yaml +244 -0
- package/v2/providers/cohere.yaml +75 -0
- package/v2/providers/deepseek.yaml +176 -0
- package/v2/providers/doubao.yaml +169 -0
- package/v2/providers/google.yaml +245 -0
- package/v2/providers/jina.yaml +55 -0
- package/v2/providers/moonshot.yaml +186 -0
- package/v2/providers/openai.yaml +266 -0
- package/v2/providers/qwen.yaml +174 -0
- package/v2/providers/zhipu.yaml +176 -0
- package/v2-alpha/providers/anthropic.yaml +134 -0
- package/v2-alpha/providers/gemini.yaml +144 -0
- package/v2-alpha/providers/openai.yaml +154 -0
- package/v2-alpha/spec.yaml +512 -0
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "https://raw.githubusercontent.com/ailib-official/ai-protocol/main/schemas/v2/context-policy.json",
|
|
4
|
+
"title": "AI-Protocol V2 Context Management Policy",
|
|
5
|
+
"description": "Context window management strategies for V2 provider manifests. Defines sliding window, summarization triggers, token budgets, and overflow handling. Provider-agnostic abstractions for managing limited context windows across varying provider capabilities.",
|
|
6
|
+
"type": "object",
|
|
7
|
+
"properties": {
|
|
8
|
+
"strategy": {
|
|
9
|
+
"type": "string",
|
|
10
|
+
"enum": ["sliding_window", "summarize", "truncate_oldest", "token_budget", "adaptive"],
|
|
11
|
+
"default": "sliding_window",
|
|
12
|
+
"description": "Primary context management strategy: sliding_window (drop oldest messages), summarize (compress old context), truncate_oldest (hard cut), token_budget (allocate per role), adaptive (auto-select based on context)"
|
|
13
|
+
},
|
|
14
|
+
"token_budget": {
|
|
15
|
+
"type": "object",
|
|
16
|
+
"description": "Token allocation budget configuration",
|
|
17
|
+
"properties": {
|
|
18
|
+
"max_context_tokens": {
|
|
19
|
+
"type": "integer",
|
|
20
|
+
"minimum": 1024,
|
|
21
|
+
"description": "Maximum tokens to use from the provider's context window (may be less than model max)"
|
|
22
|
+
},
|
|
23
|
+
"reserve_for_output": {
|
|
24
|
+
"type": "integer",
|
|
25
|
+
"minimum": 256,
|
|
26
|
+
"default": 4096,
|
|
27
|
+
"description": "Tokens reserved for model output generation"
|
|
28
|
+
},
|
|
29
|
+
"system_message_budget": {
|
|
30
|
+
"type": "integer",
|
|
31
|
+
"minimum": 0,
|
|
32
|
+
"description": "Maximum tokens for system messages (0 = unlimited within context)"
|
|
33
|
+
},
|
|
34
|
+
"tool_budget": {
|
|
35
|
+
"type": "integer",
|
|
36
|
+
"minimum": 0,
|
|
37
|
+
"description": "Maximum tokens for tool definitions and results"
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
"additionalProperties": false
|
|
41
|
+
},
|
|
42
|
+
"sliding_window": {
|
|
43
|
+
"type": "object",
|
|
44
|
+
"description": "Sliding window configuration",
|
|
45
|
+
"properties": {
|
|
46
|
+
"window_size": {
|
|
47
|
+
"type": "integer",
|
|
48
|
+
"minimum": 1,
|
|
49
|
+
"description": "Number of recent message pairs to keep"
|
|
50
|
+
},
|
|
51
|
+
"preserve_system": {
|
|
52
|
+
"type": "boolean",
|
|
53
|
+
"default": true,
|
|
54
|
+
"description": "Always keep system messages regardless of window position"
|
|
55
|
+
},
|
|
56
|
+
"preserve_tool_context": {
|
|
57
|
+
"type": "boolean",
|
|
58
|
+
"default": true,
|
|
59
|
+
"description": "Keep tool call/result pairs together (never split mid-tool-use)"
|
|
60
|
+
},
|
|
61
|
+
"anchor_messages": {
|
|
62
|
+
"type": "integer",
|
|
63
|
+
"minimum": 0,
|
|
64
|
+
"default": 0,
|
|
65
|
+
"description": "Number of initial messages to always preserve (after system)"
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
"additionalProperties": false
|
|
69
|
+
},
|
|
70
|
+
"summarization": {
|
|
71
|
+
"type": "object",
|
|
72
|
+
"description": "Context summarization configuration",
|
|
73
|
+
"properties": {
|
|
74
|
+
"enabled": {
|
|
75
|
+
"type": "boolean",
|
|
76
|
+
"default": false,
|
|
77
|
+
"description": "Enable automatic summarization of old context"
|
|
78
|
+
},
|
|
79
|
+
"trigger_threshold": {
|
|
80
|
+
"type": "number",
|
|
81
|
+
"minimum": 0.1,
|
|
82
|
+
"maximum": 1.0,
|
|
83
|
+
"default": 0.8,
|
|
84
|
+
"description": "Context fill ratio that triggers summarization (0.8 = 80% full)"
|
|
85
|
+
},
|
|
86
|
+
"summary_max_tokens": {
|
|
87
|
+
"type": "integer",
|
|
88
|
+
"minimum": 100,
|
|
89
|
+
"default": 1024,
|
|
90
|
+
"description": "Maximum tokens for the summary message"
|
|
91
|
+
},
|
|
92
|
+
"summary_model": {
|
|
93
|
+
"type": "string",
|
|
94
|
+
"description": "Model to use for summarization (if different from main model, e.g. a faster model)"
|
|
95
|
+
},
|
|
96
|
+
"preserve_recent": {
|
|
97
|
+
"type": "integer",
|
|
98
|
+
"minimum": 1,
|
|
99
|
+
"default": 5,
|
|
100
|
+
"description": "Number of recent message pairs to preserve unsummarized"
|
|
101
|
+
}
|
|
102
|
+
},
|
|
103
|
+
"additionalProperties": false
|
|
104
|
+
},
|
|
105
|
+
"overflow_handling": {
|
|
106
|
+
"type": "object",
|
|
107
|
+
"description": "What to do when context still exceeds limits after policy application",
|
|
108
|
+
"properties": {
|
|
109
|
+
"action": {
|
|
110
|
+
"type": "string",
|
|
111
|
+
"enum": ["error", "force_truncate", "retry_with_summary"],
|
|
112
|
+
"default": "error",
|
|
113
|
+
"description": "Action when context exceeds budget after policy application"
|
|
114
|
+
},
|
|
115
|
+
"error_code": {
|
|
116
|
+
"type": "string",
|
|
117
|
+
"const": "E1006",
|
|
118
|
+
"description": "Standard error code for context overflow (request_too_large)"
|
|
119
|
+
}
|
|
120
|
+
},
|
|
121
|
+
"additionalProperties": false
|
|
122
|
+
},
|
|
123
|
+
"provider_specific": {
|
|
124
|
+
"type": "object",
|
|
125
|
+
"description": "Provider-specific context management features",
|
|
126
|
+
"properties": {
|
|
127
|
+
"supports_context_caching": {
|
|
128
|
+
"type": "boolean",
|
|
129
|
+
"default": false,
|
|
130
|
+
"description": "Provider supports context caching for repeated prefixes (Gemini, Anthropic)"
|
|
131
|
+
},
|
|
132
|
+
"supports_compaction_api": {
|
|
133
|
+
"type": "boolean",
|
|
134
|
+
"default": false,
|
|
135
|
+
"description": "Provider has a native context compaction API (Anthropic)"
|
|
136
|
+
},
|
|
137
|
+
"cache_ttl_seconds": {
|
|
138
|
+
"type": "integer",
|
|
139
|
+
"minimum": 60,
|
|
140
|
+
"description": "Cache time-to-live for context caching"
|
|
141
|
+
}
|
|
142
|
+
},
|
|
143
|
+
"additionalProperties": false
|
|
144
|
+
}
|
|
145
|
+
},
|
|
146
|
+
"additionalProperties": false
|
|
147
|
+
}
|
|
148
|
+
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
{"$schema":"https://json-schema.org/draft/2020-12/schema","$id":"https://raw.githubusercontent.com/ailib-official/ai-protocol/main/schemas/v2/endpoint.json","title":"Endpoint Definition","description":"Network-level endpoint configuration for V2 provider manifests","type":"object","required":["base_url"],"properties":{"base_url":{"type":"string","format":"uri","description":"Absolute base URL of the provider API"},"protocol":{"type":"string","enum":["https","http","ws","wss"],"default":"https","description":"Protocol used for communication"},"timeout_ms":{"type":"integer","minimum":100,"default":10000,"description":"Default timeout for requests in milliseconds"},"chat":{"type":"string","description":"Chat completions endpoint path (relative to base_url)"},"embeddings":{"type":"string","description":"Embeddings endpoint path (relative to base_url)"},"stt":{"type":"string","description":"Speech-to-text transcription endpoint path (relative to base_url)"},"tts":{"type":"string","description":"Text-to-speech synthesis endpoint path (relative to base_url)"},"rerank":{"type":"string","description":"Document reranking endpoint path (relative to base_url)"},"auth":{"type":"object","description":"Authentication configuration","properties":{"type":{"type":"string","enum":["bearer","custom_header","query_param"],"description":"Authentication method"},"header":{"type":"string","description":"HTTP header name for authentication"},"prefix":{"type":"string","description":"Prefix for the auth token (e.g., 'Bearer')"},"param_name":{"type":"string","description":"Query parameter name for query_param auth"},"token_env":{"type":"string","description":"Environment variable name for the API key"},"extra_headers":{"type":"array","description":"Additional headers to include in requests","items":{"type":"object","required":["name","value"],"properties":{"name":{"type":"string"},"value":{"type":"string"}}}}},"required":["type"]}},"additionalProperties":false}
|
|
2
|
+
|
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
# AI-Protocol Standard Error Codes — Reference Data
|
|
2
|
+
# This file provides the canonical error code definitions used by all runtimes.
|
|
3
|
+
# See schemas/v2/errors.json for the JSON Schema definition.
|
|
4
|
+
|
|
5
|
+
version: "2.0"
|
|
6
|
+
last_updated: "2026-02-14"
|
|
7
|
+
|
|
8
|
+
# ==============================================================================
|
|
9
|
+
# Standard Error Codes
|
|
10
|
+
# ==============================================================================
|
|
11
|
+
# Numbering convention:
|
|
12
|
+
# E1xxx — Client errors (request-side, usually non-retryable)
|
|
13
|
+
# E2xxx — Rate/quota errors (transient, retryable with backoff)
|
|
14
|
+
# E3xxx — Server errors (provider-side, often retryable)
|
|
15
|
+
# E4xxx — Operational errors (lifecycle/state issues)
|
|
16
|
+
# E9xxx — Catch-all / unknown
|
|
17
|
+
# ==============================================================================
|
|
18
|
+
|
|
19
|
+
error_codes:
|
|
20
|
+
# --- Client Errors (1xxx) ---
|
|
21
|
+
E1001:
|
|
22
|
+
name: "invalid_request"
|
|
23
|
+
category: "client"
|
|
24
|
+
http_status: 400
|
|
25
|
+
retryable: false
|
|
26
|
+
fallbackable: false
|
|
27
|
+
description: "Malformed request, invalid parameters, or missing required fields"
|
|
28
|
+
recovery_hint: "Check request parameters against the provider's API documentation"
|
|
29
|
+
|
|
30
|
+
E1002:
|
|
31
|
+
name: "authentication"
|
|
32
|
+
category: "client"
|
|
33
|
+
http_status: 401
|
|
34
|
+
retryable: false
|
|
35
|
+
fallbackable: true
|
|
36
|
+
description: "Invalid, expired, or missing API key"
|
|
37
|
+
recovery_hint: "Verify API key is set correctly via environment variable or keyring"
|
|
38
|
+
|
|
39
|
+
E1003:
|
|
40
|
+
name: "permission_denied"
|
|
41
|
+
category: "client"
|
|
42
|
+
http_status: 403
|
|
43
|
+
retryable: false
|
|
44
|
+
fallbackable: false
|
|
45
|
+
description: "Valid credentials but insufficient permissions for the requested resource"
|
|
46
|
+
recovery_hint: "Check account permissions and model access policies"
|
|
47
|
+
|
|
48
|
+
E1004:
|
|
49
|
+
name: "not_found"
|
|
50
|
+
category: "client"
|
|
51
|
+
http_status: 404
|
|
52
|
+
retryable: false
|
|
53
|
+
fallbackable: false
|
|
54
|
+
description: "Requested model, endpoint, or resource does not exist"
|
|
55
|
+
recovery_hint: "Verify model ID and endpoint URL in the provider manifest"
|
|
56
|
+
|
|
57
|
+
E1005:
|
|
58
|
+
name: "request_too_large"
|
|
59
|
+
category: "client"
|
|
60
|
+
http_status: 413
|
|
61
|
+
retryable: false
|
|
62
|
+
fallbackable: false
|
|
63
|
+
description: "Input exceeds the model's context window or the API payload size limit"
|
|
64
|
+
recovery_hint: "Reduce input size or use a model with a larger context window"
|
|
65
|
+
|
|
66
|
+
# --- Rate/Quota Errors (2xxx) ---
|
|
67
|
+
E2001:
|
|
68
|
+
name: "rate_limited"
|
|
69
|
+
category: "rate"
|
|
70
|
+
http_status: 429
|
|
71
|
+
retryable: true
|
|
72
|
+
fallbackable: true
|
|
73
|
+
description: "Request rate limit exceeded (requests per second/minute)"
|
|
74
|
+
recovery_hint: "Retry with exponential backoff; check rate_limit_headers for timing"
|
|
75
|
+
|
|
76
|
+
E2002:
|
|
77
|
+
name: "quota_exhausted"
|
|
78
|
+
category: "rate"
|
|
79
|
+
http_status: 429
|
|
80
|
+
retryable: false
|
|
81
|
+
fallbackable: true
|
|
82
|
+
description: "Account usage quota or billing limit has been reached"
|
|
83
|
+
recovery_hint: "Upgrade plan or wait for quota reset; fallback to another provider"
|
|
84
|
+
|
|
85
|
+
# --- Server Errors (3xxx) ---
|
|
86
|
+
E3001:
|
|
87
|
+
name: "server_error"
|
|
88
|
+
category: "server"
|
|
89
|
+
http_status: 500
|
|
90
|
+
retryable: true
|
|
91
|
+
fallbackable: true
|
|
92
|
+
description: "Internal server error on the provider side"
|
|
93
|
+
recovery_hint: "Retry with backoff; if persistent, check provider status page"
|
|
94
|
+
|
|
95
|
+
E3002:
|
|
96
|
+
name: "overloaded"
|
|
97
|
+
category: "server"
|
|
98
|
+
http_status: 503
|
|
99
|
+
retryable: true
|
|
100
|
+
fallbackable: true
|
|
101
|
+
description: "Provider service is temporarily overloaded or under maintenance"
|
|
102
|
+
recovery_hint: "Retry with longer backoff; consider fallback to another provider"
|
|
103
|
+
|
|
104
|
+
E3003:
|
|
105
|
+
name: "timeout"
|
|
106
|
+
category: "server"
|
|
107
|
+
http_status: [504, 408]
|
|
108
|
+
retryable: true
|
|
109
|
+
fallbackable: true
|
|
110
|
+
description: "Request timed out before a response was received"
|
|
111
|
+
recovery_hint: "Increase timeout or reduce request complexity; retry may succeed"
|
|
112
|
+
|
|
113
|
+
# --- Operational Errors (4xxx) ---
|
|
114
|
+
E4001:
|
|
115
|
+
name: "conflict"
|
|
116
|
+
category: "operational"
|
|
117
|
+
http_status: 409
|
|
118
|
+
retryable: true
|
|
119
|
+
fallbackable: false
|
|
120
|
+
description: "State conflict, such as concurrent modification of the same resource"
|
|
121
|
+
recovery_hint: "Retry after a short delay"
|
|
122
|
+
|
|
123
|
+
E4002:
|
|
124
|
+
name: "cancelled"
|
|
125
|
+
category: "operational"
|
|
126
|
+
http_status: "N/A"
|
|
127
|
+
retryable: false
|
|
128
|
+
fallbackable: false
|
|
129
|
+
description: "Request was cancelled by the client"
|
|
130
|
+
recovery_hint: "No action needed — cancellation was intentional"
|
|
131
|
+
|
|
132
|
+
# --- Unknown (9xxx) ---
|
|
133
|
+
E9999:
|
|
134
|
+
name: "unknown"
|
|
135
|
+
category: "unknown"
|
|
136
|
+
http_status: "varies"
|
|
137
|
+
retryable: false
|
|
138
|
+
fallbackable: false
|
|
139
|
+
description: "Error could not be classified into a standard category"
|
|
140
|
+
recovery_hint: "Inspect the original provider error for details"
|
|
141
|
+
|
|
142
|
+
# ==============================================================================
|
|
143
|
+
# Provider-Specific Mappings
|
|
144
|
+
# ==============================================================================
|
|
145
|
+
# Each provider section maps their specific errors to standard error codes.
|
|
146
|
+
# Runtimes use these mappings during error classification.
|
|
147
|
+
# ==============================================================================
|
|
148
|
+
|
|
149
|
+
provider_mappings:
|
|
150
|
+
openai:
|
|
151
|
+
by_http_status:
|
|
152
|
+
"400": "invalid_request"
|
|
153
|
+
"401": "authentication"
|
|
154
|
+
"403": "permission_denied"
|
|
155
|
+
"404": "not_found"
|
|
156
|
+
"429": "rate_limited" # may also be quota_exhausted
|
|
157
|
+
"500": "server_error"
|
|
158
|
+
"503": "overloaded"
|
|
159
|
+
by_error_code:
|
|
160
|
+
"invalid_api_key": "authentication"
|
|
161
|
+
"model_not_found": "not_found"
|
|
162
|
+
"context_length_exceeded": "request_too_large"
|
|
163
|
+
"rate_limit_exceeded": "rate_limited"
|
|
164
|
+
"insufficient_quota": "quota_exhausted"
|
|
165
|
+
"server_error": "server_error"
|
|
166
|
+
by_error_message:
|
|
167
|
+
- pattern: "quota"
|
|
168
|
+
maps_to: "quota_exhausted"
|
|
169
|
+
- pattern: "billing"
|
|
170
|
+
maps_to: "quota_exhausted"
|
|
171
|
+
|
|
172
|
+
anthropic:
|
|
173
|
+
by_http_status:
|
|
174
|
+
"400": "invalid_request"
|
|
175
|
+
"401": "authentication"
|
|
176
|
+
"403": "permission_denied"
|
|
177
|
+
"404": "not_found"
|
|
178
|
+
"413": "request_too_large"
|
|
179
|
+
"429": "rate_limited"
|
|
180
|
+
"500": "server_error"
|
|
181
|
+
"529": "overloaded"
|
|
182
|
+
by_error_code:
|
|
183
|
+
"invalid_request_error": "invalid_request"
|
|
184
|
+
"authentication_error": "authentication"
|
|
185
|
+
"permission_error": "permission_denied"
|
|
186
|
+
"not_found_error": "not_found"
|
|
187
|
+
"request_too_large": "request_too_large"
|
|
188
|
+
"rate_limit_error": "rate_limited"
|
|
189
|
+
"api_error": "server_error"
|
|
190
|
+
"overloaded_error": "overloaded"
|
|
191
|
+
|
|
192
|
+
gemini:
|
|
193
|
+
by_http_status:
|
|
194
|
+
"400": "invalid_request"
|
|
195
|
+
"401": "authentication"
|
|
196
|
+
"403": "permission_denied"
|
|
197
|
+
"404": "not_found"
|
|
198
|
+
"429": "rate_limited"
|
|
199
|
+
"500": "server_error"
|
|
200
|
+
"503": "overloaded"
|
|
201
|
+
by_error_code:
|
|
202
|
+
"INVALID_ARGUMENT": "invalid_request"
|
|
203
|
+
"UNAUTHENTICATED": "authentication"
|
|
204
|
+
"PERMISSION_DENIED": "permission_denied"
|
|
205
|
+
"NOT_FOUND": "not_found"
|
|
206
|
+
"RESOURCE_EXHAUSTED": "rate_limited"
|
|
207
|
+
"INTERNAL": "server_error"
|
|
208
|
+
"UNAVAILABLE": "overloaded"
|
|
209
|
+
"DEADLINE_EXCEEDED": "timeout"
|
|
210
|
+
|
|
211
|
+
deepseek:
|
|
212
|
+
by_http_status:
|
|
213
|
+
"400": "invalid_request"
|
|
214
|
+
"401": "authentication"
|
|
215
|
+
"403": "permission_denied"
|
|
216
|
+
"404": "not_found"
|
|
217
|
+
"429": "rate_limited"
|
|
218
|
+
"500": "server_error"
|
|
219
|
+
"503": "overloaded"
|
|
220
|
+
by_error_code:
|
|
221
|
+
"invalid_request_error": "invalid_request"
|
|
222
|
+
"authentication_error": "authentication"
|
|
223
|
+
"rate_limit_reached": "rate_limited"
|
|
224
|
+
"insufficient_quota": "quota_exhausted"
|
|
225
|
+
"server_error": "server_error"
|
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "https://raw.githubusercontent.com/ailib-official/ai-protocol/main/schemas/v2/errors.json",
|
|
4
|
+
"title": "AI-Protocol Standard Error Codes",
|
|
5
|
+
"description": "Unified error code system for cross-provider error normalization. All runtimes MUST map provider-specific errors to these standard codes.",
|
|
6
|
+
"type": "object",
|
|
7
|
+
"properties": {
|
|
8
|
+
"error_codes": {
|
|
9
|
+
"type": "object",
|
|
10
|
+
"description": "Standard error code definitions, grouped by category",
|
|
11
|
+
"properties": {
|
|
12
|
+
"client_errors": {
|
|
13
|
+
"type": "object",
|
|
14
|
+
"description": "Client-side errors (1xxx range) - caused by invalid requests",
|
|
15
|
+
"properties": {
|
|
16
|
+
"E1001": {
|
|
17
|
+
"$ref": "#/$defs/error_definition",
|
|
18
|
+
"const_name": "invalid_request",
|
|
19
|
+
"description": "Malformed request, invalid parameters, or missing required fields"
|
|
20
|
+
},
|
|
21
|
+
"E1002": {
|
|
22
|
+
"$ref": "#/$defs/error_definition",
|
|
23
|
+
"const_name": "authentication",
|
|
24
|
+
"description": "Invalid, expired, or missing API key"
|
|
25
|
+
},
|
|
26
|
+
"E1003": {
|
|
27
|
+
"$ref": "#/$defs/error_definition",
|
|
28
|
+
"const_name": "permission_denied",
|
|
29
|
+
"description": "Valid credentials but insufficient permissions"
|
|
30
|
+
},
|
|
31
|
+
"E1004": {
|
|
32
|
+
"$ref": "#/$defs/error_definition",
|
|
33
|
+
"const_name": "not_found",
|
|
34
|
+
"description": "Requested model or resource does not exist"
|
|
35
|
+
},
|
|
36
|
+
"E1005": {
|
|
37
|
+
"$ref": "#/$defs/error_definition",
|
|
38
|
+
"const_name": "request_too_large",
|
|
39
|
+
"description": "Input exceeds context window or payload size limit"
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
"rate_errors": {
|
|
44
|
+
"type": "object",
|
|
45
|
+
"description": "Rate and quota errors (2xxx range) - transient capacity limits",
|
|
46
|
+
"properties": {
|
|
47
|
+
"E2001": {
|
|
48
|
+
"$ref": "#/$defs/error_definition",
|
|
49
|
+
"const_name": "rate_limited",
|
|
50
|
+
"description": "Request rate limit exceeded; retry after backoff"
|
|
51
|
+
},
|
|
52
|
+
"E2002": {
|
|
53
|
+
"$ref": "#/$defs/error_definition",
|
|
54
|
+
"const_name": "quota_exhausted",
|
|
55
|
+
"description": "Usage quota or billing limit reached"
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
"server_errors": {
|
|
60
|
+
"type": "object",
|
|
61
|
+
"description": "Server-side errors (3xxx range) - provider infrastructure issues",
|
|
62
|
+
"properties": {
|
|
63
|
+
"E3001": {
|
|
64
|
+
"$ref": "#/$defs/error_definition",
|
|
65
|
+
"const_name": "server_error",
|
|
66
|
+
"description": "Internal provider server error"
|
|
67
|
+
},
|
|
68
|
+
"E3002": {
|
|
69
|
+
"$ref": "#/$defs/error_definition",
|
|
70
|
+
"const_name": "overloaded",
|
|
71
|
+
"description": "Provider service temporarily overloaded or unavailable"
|
|
72
|
+
},
|
|
73
|
+
"E3003": {
|
|
74
|
+
"$ref": "#/$defs/error_definition",
|
|
75
|
+
"const_name": "timeout",
|
|
76
|
+
"description": "Request timed out waiting for response"
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
},
|
|
80
|
+
"operational_errors": {
|
|
81
|
+
"type": "object",
|
|
82
|
+
"description": "Operational errors (4xxx range) - state and lifecycle issues",
|
|
83
|
+
"properties": {
|
|
84
|
+
"E4001": {
|
|
85
|
+
"$ref": "#/$defs/error_definition",
|
|
86
|
+
"const_name": "conflict",
|
|
87
|
+
"description": "State conflict (e.g., concurrent modification)"
|
|
88
|
+
},
|
|
89
|
+
"E4002": {
|
|
90
|
+
"$ref": "#/$defs/error_definition",
|
|
91
|
+
"const_name": "cancelled",
|
|
92
|
+
"description": "Request cancelled by client"
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
},
|
|
96
|
+
"unknown": {
|
|
97
|
+
"type": "object",
|
|
98
|
+
"description": "Catch-all for unclassified errors",
|
|
99
|
+
"properties": {
|
|
100
|
+
"E9999": {
|
|
101
|
+
"$ref": "#/$defs/error_definition",
|
|
102
|
+
"const_name": "unknown",
|
|
103
|
+
"description": "Unclassified or unexpected error"
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
},
|
|
109
|
+
"provider_mappings": {
|
|
110
|
+
"type": "object",
|
|
111
|
+
"description": "Provider-specific error-to-standard-code mappings",
|
|
112
|
+
"additionalProperties": {
|
|
113
|
+
"$ref": "#/$defs/provider_error_mapping"
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
},
|
|
117
|
+
"$defs": {
|
|
118
|
+
"error_definition": {
|
|
119
|
+
"type": "object",
|
|
120
|
+
"required": ["code", "name", "http_status", "retryable", "fallbackable"],
|
|
121
|
+
"properties": {
|
|
122
|
+
"code": {
|
|
123
|
+
"type": "string",
|
|
124
|
+
"pattern": "^E[0-9]{4}$",
|
|
125
|
+
"description": "Standard error code (E + 4 digits)"
|
|
126
|
+
},
|
|
127
|
+
"name": {
|
|
128
|
+
"type": "string",
|
|
129
|
+
"description": "Machine-readable error name (snake_case)"
|
|
130
|
+
},
|
|
131
|
+
"http_status": {
|
|
132
|
+
"oneOf": [
|
|
133
|
+
{ "type": "integer", "minimum": 100, "maximum": 599 },
|
|
134
|
+
{ "type": "array", "items": { "type": "integer" } },
|
|
135
|
+
{ "type": "string", "enum": ["varies", "N/A"] }
|
|
136
|
+
],
|
|
137
|
+
"description": "Associated HTTP status code(s)"
|
|
138
|
+
},
|
|
139
|
+
"retryable": {
|
|
140
|
+
"type": "boolean",
|
|
141
|
+
"description": "Whether the same request can be retried"
|
|
142
|
+
},
|
|
143
|
+
"fallbackable": {
|
|
144
|
+
"type": "boolean",
|
|
145
|
+
"description": "Whether the request can be sent to a different provider/model"
|
|
146
|
+
},
|
|
147
|
+
"category": {
|
|
148
|
+
"type": "string",
|
|
149
|
+
"enum": ["client", "rate", "server", "operational", "unknown"],
|
|
150
|
+
"description": "Error category for grouping"
|
|
151
|
+
},
|
|
152
|
+
"description": {
|
|
153
|
+
"type": "string",
|
|
154
|
+
"description": "Human-readable description of the error"
|
|
155
|
+
},
|
|
156
|
+
"recovery_hint": {
|
|
157
|
+
"type": "string",
|
|
158
|
+
"description": "Suggested recovery action for developers"
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
},
|
|
162
|
+
"provider_error_mapping": {
|
|
163
|
+
"type": "object",
|
|
164
|
+
"description": "Maps provider-specific errors to standard error codes",
|
|
165
|
+
"properties": {
|
|
166
|
+
"by_http_status": {
|
|
167
|
+
"type": "object",
|
|
168
|
+
"description": "HTTP status code to standard error code mapping",
|
|
169
|
+
"additionalProperties": {
|
|
170
|
+
"type": "string",
|
|
171
|
+
"description": "Standard error name (e.g., 'invalid_request', 'rate_limited')"
|
|
172
|
+
}
|
|
173
|
+
},
|
|
174
|
+
"by_error_code": {
|
|
175
|
+
"type": "object",
|
|
176
|
+
"description": "Provider-specific error code to standard error code mapping",
|
|
177
|
+
"additionalProperties": {
|
|
178
|
+
"type": "string",
|
|
179
|
+
"description": "Standard error name"
|
|
180
|
+
}
|
|
181
|
+
},
|
|
182
|
+
"by_error_message": {
|
|
183
|
+
"type": "array",
|
|
184
|
+
"description": "Pattern-based error message classification",
|
|
185
|
+
"items": {
|
|
186
|
+
"type": "object",
|
|
187
|
+
"required": ["pattern", "maps_to"],
|
|
188
|
+
"properties": {
|
|
189
|
+
"pattern": {
|
|
190
|
+
"type": "string",
|
|
191
|
+
"description": "Regex pattern to match against error message"
|
|
192
|
+
},
|
|
193
|
+
"maps_to": {
|
|
194
|
+
"type": "string",
|
|
195
|
+
"description": "Standard error name to map to"
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
},
|
|
202
|
+
"error_response_envelope": {
|
|
203
|
+
"type": "object",
|
|
204
|
+
"description": "Standard error response format returned by runtimes",
|
|
205
|
+
"required": ["error"],
|
|
206
|
+
"properties": {
|
|
207
|
+
"error": {
|
|
208
|
+
"type": "object",
|
|
209
|
+
"required": ["code", "name", "message"],
|
|
210
|
+
"properties": {
|
|
211
|
+
"code": {
|
|
212
|
+
"type": "string",
|
|
213
|
+
"pattern": "^E[0-9]{4}$",
|
|
214
|
+
"description": "Standard error code"
|
|
215
|
+
},
|
|
216
|
+
"name": {
|
|
217
|
+
"type": "string",
|
|
218
|
+
"description": "Standard error name"
|
|
219
|
+
},
|
|
220
|
+
"message": {
|
|
221
|
+
"type": "string",
|
|
222
|
+
"description": "Human-readable error description"
|
|
223
|
+
},
|
|
224
|
+
"provider_error": {
|
|
225
|
+
"type": "object",
|
|
226
|
+
"description": "Original provider error details (for debugging)",
|
|
227
|
+
"properties": {
|
|
228
|
+
"status_code": { "type": "integer" },
|
|
229
|
+
"error_code": { "type": "string" },
|
|
230
|
+
"error_message": { "type": "string" },
|
|
231
|
+
"raw": { "description": "Raw provider error body" }
|
|
232
|
+
}
|
|
233
|
+
},
|
|
234
|
+
"retryable": { "type": "boolean" },
|
|
235
|
+
"fallbackable": { "type": "boolean" },
|
|
236
|
+
"retry_after_ms": {
|
|
237
|
+
"type": "integer",
|
|
238
|
+
"description": "Suggested retry delay in milliseconds"
|
|
239
|
+
},
|
|
240
|
+
"request_id": {
|
|
241
|
+
"type": "string",
|
|
242
|
+
"description": "Request ID for correlation"
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
|