@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,134 @@
|
|
|
1
|
+
# AI-Protocol V2-Alpha: Anthropic Provider Manifest
|
|
2
|
+
# Migrated from v1/providers/anthropic.yaml with V2 structured capabilities
|
|
3
|
+
$schema: "https://raw.githubusercontent.com/ailib-official/ai-protocol/main/schemas/v2/provider.json"
|
|
4
|
+
|
|
5
|
+
# === Ring 1: Core Skeleton ===
|
|
6
|
+
id: anthropic
|
|
7
|
+
protocol_version: "2.0"
|
|
8
|
+
name: "Anthropic"
|
|
9
|
+
version: "v1"
|
|
10
|
+
status: stable
|
|
11
|
+
category: ai_provider
|
|
12
|
+
official_url: "https://docs.anthropic.com"
|
|
13
|
+
support_contact: "https://support.anthropic.com"
|
|
14
|
+
|
|
15
|
+
endpoint:
|
|
16
|
+
base_url: "https://api.anthropic.com/v1"
|
|
17
|
+
chat: "/messages"
|
|
18
|
+
auth:
|
|
19
|
+
type: "custom_header"
|
|
20
|
+
header: "x-api-key"
|
|
21
|
+
token_env: "ANTHROPIC_API_KEY"
|
|
22
|
+
extra_headers:
|
|
23
|
+
- name: "anthropic-version"
|
|
24
|
+
value: "2023-06-01"
|
|
25
|
+
|
|
26
|
+
error_classification:
|
|
27
|
+
by_http_status:
|
|
28
|
+
"400": "invalid_request"
|
|
29
|
+
"401": "authentication"
|
|
30
|
+
"403": "permission_denied"
|
|
31
|
+
"404": "not_found"
|
|
32
|
+
"413": "request_too_large"
|
|
33
|
+
"429": "rate_limited"
|
|
34
|
+
"500": "server_error"
|
|
35
|
+
"529": "overloaded"
|
|
36
|
+
by_error_code:
|
|
37
|
+
"invalid_request_error": "invalid_request"
|
|
38
|
+
"authentication_error": "authentication"
|
|
39
|
+
"permission_error": "permission_denied"
|
|
40
|
+
"not_found_error": "not_found"
|
|
41
|
+
"request_too_large": "request_too_large"
|
|
42
|
+
"rate_limit_error": "rate_limited"
|
|
43
|
+
"api_error": "server_error"
|
|
44
|
+
"overloaded_error": "overloaded"
|
|
45
|
+
|
|
46
|
+
# === Ring 2: Capability Mapping ===
|
|
47
|
+
capabilities:
|
|
48
|
+
required:
|
|
49
|
+
- text
|
|
50
|
+
- streaming
|
|
51
|
+
optional:
|
|
52
|
+
- vision
|
|
53
|
+
- tools
|
|
54
|
+
- parallel_tools
|
|
55
|
+
- agentic
|
|
56
|
+
- reasoning
|
|
57
|
+
- batch
|
|
58
|
+
feature_flags:
|
|
59
|
+
structured_output: false
|
|
60
|
+
parallel_tool_calls: true
|
|
61
|
+
extended_thinking: true
|
|
62
|
+
streaming_usage: true
|
|
63
|
+
system_messages: true
|
|
64
|
+
|
|
65
|
+
parameters:
|
|
66
|
+
temperature: { type: float, range: [0.0, 2.0], default: 1.0 }
|
|
67
|
+
# provider_specific_constraints:
|
|
68
|
+
# max_value_override: 1.0 # Anthropic实际限制为[0.0, 1.0]
|
|
69
|
+
max_tokens: { type: integer, min: 1, max: 8192, required: true }
|
|
70
|
+
top_p: { type: float, range: [0.0, 1.0] }
|
|
71
|
+
top_k: { type: integer, min: 0 }
|
|
72
|
+
stream: { type: boolean }
|
|
73
|
+
|
|
74
|
+
streaming:
|
|
75
|
+
decoder:
|
|
76
|
+
format: "anthropic_sse"
|
|
77
|
+
strategy: "anthropic_event_stream"
|
|
78
|
+
event_map:
|
|
79
|
+
- match: "$.type == 'content_block_delta' && $.delta.type == 'text_delta'"
|
|
80
|
+
emit: "PartialContentDelta"
|
|
81
|
+
extract:
|
|
82
|
+
content: "$.delta.text"
|
|
83
|
+
- match: "$.type == 'content_block_delta' && $.delta.type == 'input_json_delta'"
|
|
84
|
+
emit: "PartialToolCall"
|
|
85
|
+
extract:
|
|
86
|
+
partial_json: "$.delta.partial_json"
|
|
87
|
+
- match: "$.type == 'content_block_delta' && $.delta.type == 'thinking_delta'"
|
|
88
|
+
emit: "ThinkingDelta"
|
|
89
|
+
extract:
|
|
90
|
+
thinking: "$.delta.thinking"
|
|
91
|
+
- match: "$.type == 'message_delta'"
|
|
92
|
+
emit: "StreamEnd"
|
|
93
|
+
extract:
|
|
94
|
+
finish_reason: "$.delta.stop_reason"
|
|
95
|
+
usage: "$.usage"
|
|
96
|
+
accumulator:
|
|
97
|
+
stateful_tool_parsing: true
|
|
98
|
+
key_path: "$.delta.partial_json"
|
|
99
|
+
flush_on: "$.type == 'content_block_stop'"
|
|
100
|
+
|
|
101
|
+
# === Ring 3: Advanced Extensions ===
|
|
102
|
+
api_families: ["messages"]
|
|
103
|
+
default_api_family: "messages"
|
|
104
|
+
|
|
105
|
+
endpoints:
|
|
106
|
+
chat:
|
|
107
|
+
path: "/messages"
|
|
108
|
+
method: "POST"
|
|
109
|
+
adapter: "anthropic"
|
|
110
|
+
|
|
111
|
+
rate_limit_headers:
|
|
112
|
+
# Provider-specific headers (保留用于原始响应解析)
|
|
113
|
+
# Normalized fields (rate_limit_*) are auto-filled by runtime parser.
|
|
114
|
+
retry_after: "retry-after"
|
|
115
|
+
requests_limit: "anthropic-ratelimit-requests-limit"
|
|
116
|
+
requests_remaining: "anthropic-ratelimit-requests-remaining"
|
|
117
|
+
tokens_limit: "anthropic-ratelimit-tokens-limit"
|
|
118
|
+
tokens_remaining: "anthropic-ratelimit-tokens-remaining"
|
|
119
|
+
|
|
120
|
+
retry_policy:
|
|
121
|
+
strategy: "exponential_backoff"
|
|
122
|
+
max_retries: 2
|
|
123
|
+
min_delay_ms: 1000
|
|
124
|
+
max_delay_ms: 60000
|
|
125
|
+
jitter: "full"
|
|
126
|
+
retry_on_http_status: [408, 409, 429, 500, 529]
|
|
127
|
+
|
|
128
|
+
termination:
|
|
129
|
+
source_field: "stop_reason"
|
|
130
|
+
mapping:
|
|
131
|
+
end_turn: "end_turn"
|
|
132
|
+
max_tokens: "max_tokens"
|
|
133
|
+
stop_sequence: "stop_sequence"
|
|
134
|
+
tool_use: "tool_use"
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
# AI-Protocol V2-Alpha: Google Gemini Provider Manifest
|
|
2
|
+
# Migrated from v1/providers/gemini.yaml with V2 structured capabilities
|
|
3
|
+
$schema: "https://raw.githubusercontent.com/ailib-official/ai-protocol/main/schemas/v2/provider.json"
|
|
4
|
+
|
|
5
|
+
# === Ring 1: Core Skeleton ===
|
|
6
|
+
id: gemini
|
|
7
|
+
protocol_version: "2.0"
|
|
8
|
+
name: "Google Gemini"
|
|
9
|
+
version: "v1beta"
|
|
10
|
+
status: stable
|
|
11
|
+
category: ai_provider
|
|
12
|
+
official_url: "https://ai.google.dev/docs"
|
|
13
|
+
support_contact: "https://support.google.com/gemini"
|
|
14
|
+
|
|
15
|
+
endpoint:
|
|
16
|
+
base_url: "https://generativelanguage.googleapis.com/v1beta"
|
|
17
|
+
chat: "/models/{model}:generateContent"
|
|
18
|
+
auth:
|
|
19
|
+
type: "query_param"
|
|
20
|
+
param_name: "key"
|
|
21
|
+
token_env: "GEMINI_API_KEY"
|
|
22
|
+
|
|
23
|
+
error_classification:
|
|
24
|
+
by_http_status:
|
|
25
|
+
"400": "invalid_request"
|
|
26
|
+
"401": "authentication"
|
|
27
|
+
"403": "permission_denied"
|
|
28
|
+
"404": "not_found"
|
|
29
|
+
"429": "rate_limited"
|
|
30
|
+
"500": "server_error"
|
|
31
|
+
"503": "overloaded"
|
|
32
|
+
by_error_code:
|
|
33
|
+
"INVALID_ARGUMENT": "invalid_request"
|
|
34
|
+
"UNAUTHENTICATED": "authentication"
|
|
35
|
+
"PERMISSION_DENIED": "permission_denied"
|
|
36
|
+
"NOT_FOUND": "not_found"
|
|
37
|
+
"RESOURCE_EXHAUSTED": "rate_limited"
|
|
38
|
+
"INTERNAL": "server_error"
|
|
39
|
+
"UNAVAILABLE": "overloaded"
|
|
40
|
+
"DEADLINE_EXCEEDED": "timeout"
|
|
41
|
+
|
|
42
|
+
# === Ring 2: Capability Mapping ===
|
|
43
|
+
capabilities:
|
|
44
|
+
required:
|
|
45
|
+
- text
|
|
46
|
+
- streaming
|
|
47
|
+
optional:
|
|
48
|
+
- vision
|
|
49
|
+
- audio
|
|
50
|
+
- video
|
|
51
|
+
- tools
|
|
52
|
+
- parallel_tools
|
|
53
|
+
- reasoning
|
|
54
|
+
- embeddings
|
|
55
|
+
- structured_output
|
|
56
|
+
feature_flags:
|
|
57
|
+
structured_output: true
|
|
58
|
+
parallel_tool_calls: true
|
|
59
|
+
extended_thinking: true
|
|
60
|
+
streaming_usage: false
|
|
61
|
+
system_messages: true
|
|
62
|
+
|
|
63
|
+
parameters:
|
|
64
|
+
temperature: { type: float, range: [0.0, 2.0], default: 1.0 }
|
|
65
|
+
maxOutputTokens: { type: integer, min: 1, max: 65536, alias: "max_tokens", deprecated: true, required: true }
|
|
66
|
+
topP: { type: float, range: [0.0, 1.0], alias: "top_p", deprecated: true }
|
|
67
|
+
topK: { type: integer, min: 0, alias: "top_k", deprecated: true }
|
|
68
|
+
|
|
69
|
+
streaming:
|
|
70
|
+
decoder:
|
|
71
|
+
format: "gemini_sse"
|
|
72
|
+
strategy: "gemini_generate"
|
|
73
|
+
event_map:
|
|
74
|
+
- match: "$.candidates[0].content.parts[0].text"
|
|
75
|
+
emit: "PartialContentDelta"
|
|
76
|
+
extract:
|
|
77
|
+
content: "$.candidates[0].content.parts[0].text"
|
|
78
|
+
- match: "$.candidates[0].content.parts[0].functionCall"
|
|
79
|
+
emit: "PartialToolCall"
|
|
80
|
+
extract:
|
|
81
|
+
tool_call: "$.candidates[0].content.parts[0].functionCall"
|
|
82
|
+
- match: "$.candidates[0].finishReason"
|
|
83
|
+
emit: "StreamEnd"
|
|
84
|
+
extract:
|
|
85
|
+
finish_reason: "$.candidates[0].finishReason"
|
|
86
|
+
candidate:
|
|
87
|
+
candidate_id_path: "$.candidates[*].index"
|
|
88
|
+
fan_out: true
|
|
89
|
+
|
|
90
|
+
# === Ring 3: Advanced Extensions ===
|
|
91
|
+
api_families: ["generate_content"]
|
|
92
|
+
default_api_family: "generate_content"
|
|
93
|
+
|
|
94
|
+
endpoints:
|
|
95
|
+
chat:
|
|
96
|
+
path: "/models/{model}:generateContent"
|
|
97
|
+
method: "POST"
|
|
98
|
+
adapter: "gemini"
|
|
99
|
+
stream_chat:
|
|
100
|
+
path: "/models/{model}:streamGenerateContent"
|
|
101
|
+
method: "POST"
|
|
102
|
+
adapter: "gemini"
|
|
103
|
+
embeddings:
|
|
104
|
+
path: "/models/{model}:embedContent"
|
|
105
|
+
method: "POST"
|
|
106
|
+
adapter: "gemini"
|
|
107
|
+
|
|
108
|
+
services:
|
|
109
|
+
list_models:
|
|
110
|
+
path: "/models"
|
|
111
|
+
method: "GET"
|
|
112
|
+
response_binding: "models"
|
|
113
|
+
get_model:
|
|
114
|
+
path: "/models/{model}"
|
|
115
|
+
method: "GET"
|
|
116
|
+
|
|
117
|
+
rate_limit_headers:
|
|
118
|
+
# Provider-specific headers (Gemini 没有rate limit头部)
|
|
119
|
+
# Normalized fields (运行时标准访问)
|
|
120
|
+
# rate_limit_requests_limit: (配置为null,Gemini不支持)
|
|
121
|
+
# rate_limit_requests_remaining: (配置为null,Gemini不支持)
|
|
122
|
+
# rate_limit_tokens_limit: (配置为null,Gemini不支持)
|
|
123
|
+
# rate_limit_tokens_remaining: (配置为null,Gemini不支持)
|
|
124
|
+
# rate_limit_retry_after: (配置为null,Gemini不支持)
|
|
125
|
+
# Empty object (Gemini does not support rate limit headers)
|
|
126
|
+
{}
|
|
127
|
+
retry_policy:
|
|
128
|
+
strategy: "exponential_backoff"
|
|
129
|
+
max_retries: 3
|
|
130
|
+
min_delay_ms: 1000
|
|
131
|
+
max_delay_ms: 30000
|
|
132
|
+
jitter: "full"
|
|
133
|
+
retry_on_http_status: [429, 500, 503]
|
|
134
|
+
|
|
135
|
+
termination:
|
|
136
|
+
source_field: "finishReason"
|
|
137
|
+
mapping:
|
|
138
|
+
STOP: "end_turn"
|
|
139
|
+
MAX_TOKENS: "max_tokens"
|
|
140
|
+
SAFETY: "refusal"
|
|
141
|
+
RECITATION: "refusal"
|
|
142
|
+
OTHER: "other"
|
|
143
|
+
BLOCKLIST: "refusal"
|
|
144
|
+
PROHIBITED_CONTENT: "refusal"
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
# AI-Protocol V2-Alpha: OpenAI Provider Manifest
|
|
2
|
+
# Migrated from v1/providers/openai.yaml with V2 structured capabilities
|
|
3
|
+
$schema: "https://raw.githubusercontent.com/ailib-official/ai-protocol/main/schemas/v2/provider.json"
|
|
4
|
+
|
|
5
|
+
# === Ring 1: Core Skeleton ===
|
|
6
|
+
id: openai
|
|
7
|
+
protocol_version: "2.0"
|
|
8
|
+
name: "OpenAI"
|
|
9
|
+
version: "v1"
|
|
10
|
+
status: stable
|
|
11
|
+
category: ai_provider
|
|
12
|
+
official_url: "https://platform.openai.com/docs"
|
|
13
|
+
support_contact: "https://help.openai.com"
|
|
14
|
+
|
|
15
|
+
endpoint:
|
|
16
|
+
base_url: "https://api.openai.com/v1"
|
|
17
|
+
chat: "/chat/completions"
|
|
18
|
+
embeddings: "/embeddings"
|
|
19
|
+
auth:
|
|
20
|
+
type: "bearer"
|
|
21
|
+
header: "Authorization"
|
|
22
|
+
prefix: "Bearer"
|
|
23
|
+
token_env: "OPENAI_API_KEY"
|
|
24
|
+
|
|
25
|
+
error_classification:
|
|
26
|
+
by_http_status:
|
|
27
|
+
"400": "invalid_request"
|
|
28
|
+
"401": "authentication"
|
|
29
|
+
"403": "permission_denied"
|
|
30
|
+
"404": "not_found"
|
|
31
|
+
"429": "rate_limited"
|
|
32
|
+
"500": "server_error"
|
|
33
|
+
"503": "overloaded"
|
|
34
|
+
by_error_code:
|
|
35
|
+
"invalid_api_key": "authentication"
|
|
36
|
+
"model_not_found": "not_found"
|
|
37
|
+
"context_length_exceeded": "request_too_large"
|
|
38
|
+
"rate_limit_exceeded": "rate_limited"
|
|
39
|
+
"insufficient_quota": "quota_exhausted"
|
|
40
|
+
"server_error": "server_error"
|
|
41
|
+
|
|
42
|
+
# === Ring 2: Capability Mapping ===
|
|
43
|
+
capabilities:
|
|
44
|
+
required:
|
|
45
|
+
- text
|
|
46
|
+
- streaming
|
|
47
|
+
optional:
|
|
48
|
+
- vision
|
|
49
|
+
- tools
|
|
50
|
+
- parallel_tools
|
|
51
|
+
- embeddings
|
|
52
|
+
- structured_output
|
|
53
|
+
- batch
|
|
54
|
+
- audio
|
|
55
|
+
- image_generation
|
|
56
|
+
feature_flags:
|
|
57
|
+
structured_output: true
|
|
58
|
+
parallel_tool_calls: true
|
|
59
|
+
streaming_usage: true
|
|
60
|
+
system_messages: true
|
|
61
|
+
image_generation: true
|
|
62
|
+
|
|
63
|
+
parameters:
|
|
64
|
+
temperature: { type: float, range: [0.0, 2.0], default: 1.0 }
|
|
65
|
+
max_tokens: { type: integer, min: 1, max: 128000, required: true }
|
|
66
|
+
top_p: { type: float, range: [0.0, 1.0] }
|
|
67
|
+
frequency_penalty: { type: float, range: [-2.0, 2.0] }
|
|
68
|
+
presence_penalty: { type: float, range: [-2.0, 2.0] }
|
|
69
|
+
stream: { type: boolean }
|
|
70
|
+
n: { type: integer, min: 1 }
|
|
71
|
+
response_format: { type: object }
|
|
72
|
+
|
|
73
|
+
streaming:
|
|
74
|
+
decoder:
|
|
75
|
+
format: "sse"
|
|
76
|
+
strategy: "openai_chat"
|
|
77
|
+
done_signal: "[DONE]"
|
|
78
|
+
prefix: "data: "
|
|
79
|
+
event_map:
|
|
80
|
+
- match: "$.choices[0].delta.content"
|
|
81
|
+
emit: "PartialContentDelta"
|
|
82
|
+
extract:
|
|
83
|
+
content: "$.choices[0].delta.content"
|
|
84
|
+
- match: "$.choices[0].delta.tool_calls"
|
|
85
|
+
emit: "PartialToolCall"
|
|
86
|
+
extract:
|
|
87
|
+
tool_calls: "$.choices[0].delta.tool_calls"
|
|
88
|
+
- match: "$.choices[0].finish_reason"
|
|
89
|
+
emit: "StreamEnd"
|
|
90
|
+
extract:
|
|
91
|
+
finish_reason: "$.choices[0].finish_reason"
|
|
92
|
+
- match: "$.usage"
|
|
93
|
+
emit: "UsageReport"
|
|
94
|
+
extract:
|
|
95
|
+
usage: "$.usage"
|
|
96
|
+
candidate:
|
|
97
|
+
candidate_id_path: "$.choices[*].index"
|
|
98
|
+
fan_out: true
|
|
99
|
+
accumulator:
|
|
100
|
+
stateful_tool_parsing: true
|
|
101
|
+
key_path: "$.choices[0].delta.tool_calls[0].function.arguments"
|
|
102
|
+
flush_on: "$.choices[0].finish_reason == 'tool_calls'"
|
|
103
|
+
|
|
104
|
+
# === Ring 3: Advanced Extensions ===
|
|
105
|
+
api_families: ["chat_completions", "completions", "embeddings", "assistants", "realtime"]
|
|
106
|
+
default_api_family: "chat_completions"
|
|
107
|
+
|
|
108
|
+
endpoints:
|
|
109
|
+
chat:
|
|
110
|
+
path: "/chat/completions"
|
|
111
|
+
method: "POST"
|
|
112
|
+
adapter: "openai"
|
|
113
|
+
embeddings:
|
|
114
|
+
path: "/embeddings"
|
|
115
|
+
method: "POST"
|
|
116
|
+
adapter: "openai"
|
|
117
|
+
|
|
118
|
+
services:
|
|
119
|
+
list_models:
|
|
120
|
+
path: "/models"
|
|
121
|
+
method: "GET"
|
|
122
|
+
response_binding: "data"
|
|
123
|
+
|
|
124
|
+
rate_limit_headers:
|
|
125
|
+
# Provider-specific headers (保留用于原始响应解析)
|
|
126
|
+
requests_limit: "x-ratelimit-limit-requests"
|
|
127
|
+
requests_remaining: "x-ratelimit-remaining-requests"
|
|
128
|
+
tokens_limit: "x-ratelimit-limit-tokens"
|
|
129
|
+
tokens_remaining: "x-ratelimit-remaining-tokens"
|
|
130
|
+
retry_after: null
|
|
131
|
+
# Normalized fields (运行时标准访问)
|
|
132
|
+
# rate_limit_requests_limit: (自动解析并填充)
|
|
133
|
+
# rate_limit_requests_remaining: (自动解析并填充)
|
|
134
|
+
# rate_limit_requests_reset: (自动解析并填充)
|
|
135
|
+
# rate_limit_tokens_limit: (自动解析并填充)
|
|
136
|
+
# rate_limit_tokens_remaining: (自动解析并填充)
|
|
137
|
+
# rate_limit_tokens_reset: (自动解析并填充)
|
|
138
|
+
# rate_limit_retry_after: (自动解析并填充)
|
|
139
|
+
retry_policy:
|
|
140
|
+
strategy: "exponential_backoff"
|
|
141
|
+
max_retries: 3
|
|
142
|
+
min_delay_ms: 1000
|
|
143
|
+
max_delay_ms: 30000
|
|
144
|
+
jitter: "full"
|
|
145
|
+
retry_on_http_status: [429, 500, 502, 503]
|
|
146
|
+
|
|
147
|
+
termination:
|
|
148
|
+
source_field: "finish_reason"
|
|
149
|
+
mapping:
|
|
150
|
+
stop: "end_turn"
|
|
151
|
+
length: "max_tokens"
|
|
152
|
+
content_filter: "refusal"
|
|
153
|
+
tool_calls: "tool_use"
|
|
154
|
+
function_call: "tool_use"
|