@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.
Files changed (194) hide show
  1. package/LICENSE +6 -0
  2. package/README.md +415 -0
  3. package/dist/index.json +8 -0
  4. package/dist/v1/models/ai21.json +140 -0
  5. package/dist/v1/models/baichuan.json +138 -0
  6. package/dist/v1/models/cerebras.json +147 -0
  7. package/dist/v1/models/claude.json +114 -0
  8. package/dist/v1/models/cohere.json +235 -0
  9. package/dist/v1/models/deepinfra.json +43 -0
  10. package/dist/v1/models/deepseek-chat.json +55 -0
  11. package/dist/v1/models/doubao.json +197 -0
  12. package/dist/v1/models/ernie.json +223 -0
  13. package/dist/v1/models/fireworks.json +222 -0
  14. package/dist/v1/models/gemini.json +58 -0
  15. package/dist/v1/models/gpt.json +166 -0
  16. package/dist/v1/models/grok.json +138 -0
  17. package/dist/v1/models/huggingface.json +183 -0
  18. package/dist/v1/models/hunyuan.json +255 -0
  19. package/dist/v1/models/jina.json +139 -0
  20. package/dist/v1/models/lepton.json +188 -0
  21. package/dist/v1/models/llama.json +143 -0
  22. package/dist/v1/models/minimax.json +194 -0
  23. package/dist/v1/models/mistral.json +177 -0
  24. package/dist/v1/models/moonshot.json +144 -0
  25. package/dist/v1/models/nvidia.json +212 -0
  26. package/dist/v1/models/palmyra.json +103 -0
  27. package/dist/v1/models/perplexity.json +143 -0
  28. package/dist/v1/models/qwen.json +49 -0
  29. package/dist/v1/models/replicate.json +206 -0
  30. package/dist/v1/models/sensenova.json +144 -0
  31. package/dist/v1/models/siliconflow.json +44 -0
  32. package/dist/v1/models/spark.json +173 -0
  33. package/dist/v1/models/stable-diffusion.json +161 -0
  34. package/dist/v1/models/tiangong.json +169 -0
  35. package/dist/v1/models/together.json +43 -0
  36. package/dist/v1/models/yi.json +199 -0
  37. package/dist/v1/models/zhipu.json +250 -0
  38. package/dist/v1/providers/ai21.json +215 -0
  39. package/dist/v1/providers/anthropic.json +253 -0
  40. package/dist/v1/providers/anyscale.json +115 -0
  41. package/dist/v1/providers/azure.json +188 -0
  42. package/dist/v1/providers/baichuan.json +205 -0
  43. package/dist/v1/providers/baidu.json +205 -0
  44. package/dist/v1/providers/cerebras.json +216 -0
  45. package/dist/v1/providers/cohere.json +209 -0
  46. package/dist/v1/providers/deepinfra.json +196 -0
  47. package/dist/v1/providers/deepseek.json +221 -0
  48. package/dist/v1/providers/doubao.json +209 -0
  49. package/dist/v1/providers/fireworks.json +227 -0
  50. package/dist/v1/providers/gemini.json +279 -0
  51. package/dist/v1/providers/groq.json +218 -0
  52. package/dist/v1/providers/huggingface.json +181 -0
  53. package/dist/v1/providers/hunyuan.json +198 -0
  54. package/dist/v1/providers/jina.json +202 -0
  55. package/dist/v1/providers/lepton.json +221 -0
  56. package/dist/v1/providers/minimax.json +209 -0
  57. package/dist/v1/providers/mistral.json +214 -0
  58. package/dist/v1/providers/moonshot.json +214 -0
  59. package/dist/v1/providers/nvidia.json +213 -0
  60. package/dist/v1/providers/openai.json +267 -0
  61. package/dist/v1/providers/openrouter.json +220 -0
  62. package/dist/v1/providers/perplexity.json +172 -0
  63. package/dist/v1/providers/qwen.json +231 -0
  64. package/dist/v1/providers/replicate.json +192 -0
  65. package/dist/v1/providers/sensenova.json +185 -0
  66. package/dist/v1/providers/siliconflow.json +197 -0
  67. package/dist/v1/providers/spark.json +204 -0
  68. package/dist/v1/providers/stability.json +221 -0
  69. package/dist/v1/providers/tiangong.json +207 -0
  70. package/dist/v1/providers/together.json +196 -0
  71. package/dist/v1/providers/writer.json +253 -0
  72. package/dist/v1/providers/xai.json +238 -0
  73. package/dist/v1/providers/yi.json +205 -0
  74. package/dist/v1/providers/zhipu.json +208 -0
  75. package/dist/v1/spec.json +783 -0
  76. package/dist/v2/providers/anthropic.json +372 -0
  77. package/dist/v2/providers/cohere.json +109 -0
  78. package/dist/v2/providers/deepseek.json +272 -0
  79. package/dist/v2/providers/doubao.json +260 -0
  80. package/dist/v2/providers/google.json +388 -0
  81. package/dist/v2/providers/jina.json +71 -0
  82. package/dist/v2/providers/moonshot.json +284 -0
  83. package/dist/v2/providers/openai.json +419 -0
  84. package/dist/v2/providers/qwen.json +274 -0
  85. package/dist/v2/providers/zhipu.json +257 -0
  86. package/dist/v2-alpha/providers/anthropic.json +182 -0
  87. package/dist/v2-alpha/providers/gemini.json +187 -0
  88. package/dist/v2-alpha/providers/openai.json +215 -0
  89. package/dist/v2-alpha/spec.json +644 -0
  90. package/package.json +61 -0
  91. package/schemas/spec.json +186 -0
  92. package/schemas/v1.json +1116 -0
  93. package/schemas/v2/availability.json +66 -0
  94. package/schemas/v2/capabilities.json +182 -0
  95. package/schemas/v2/capability-profile.json +174 -0
  96. package/schemas/v2/computer-use.json +222 -0
  97. package/schemas/v2/context-policy.json +148 -0
  98. package/schemas/v2/endpoint.json +2 -0
  99. package/schemas/v2/error-codes.yaml +225 -0
  100. package/schemas/v2/errors.json +250 -0
  101. package/schemas/v2/execution-metadata.json +59 -0
  102. package/schemas/v2/mcp.json +225 -0
  103. package/schemas/v2/message-roles.json +10 -0
  104. package/schemas/v2/multimodal.json +297 -0
  105. package/schemas/v2/pricing.json +14 -0
  106. package/schemas/v2/provider-contract.json +317 -0
  107. package/schemas/v2/provider.json +203 -0
  108. package/schemas/v2/regions.json +14 -0
  109. package/v1/models/ai21.yaml +97 -0
  110. package/v1/models/baichuan.yaml +95 -0
  111. package/v1/models/cerebras.yaml +99 -0
  112. package/v1/models/claude.yaml +59 -0
  113. package/v1/models/cohere.yaml +165 -0
  114. package/v1/models/deepinfra.yaml +29 -0
  115. package/v1/models/deepseek-chat.yaml +32 -0
  116. package/v1/models/doubao.yaml +129 -0
  117. package/v1/models/ernie.yaml +146 -0
  118. package/v1/models/fireworks.yaml +145 -0
  119. package/v1/models/gemini.yaml +32 -0
  120. package/v1/models/gpt.yaml +90 -0
  121. package/v1/models/grok.yaml +74 -0
  122. package/v1/models/huggingface.yaml +110 -0
  123. package/v1/models/hunyuan.yaml +164 -0
  124. package/v1/models/jina.yaml +98 -0
  125. package/v1/models/lepton.yaml +130 -0
  126. package/v1/models/llama.yaml +91 -0
  127. package/v1/models/minimax.yaml +132 -0
  128. package/v1/models/mistral.yaml +100 -0
  129. package/v1/models/moonshot.yaml +97 -0
  130. package/v1/models/nvidia.yaml +118 -0
  131. package/v1/models/palmyra.yaml +59 -0
  132. package/v1/models/perplexity.yaml +97 -0
  133. package/v1/models/qwen.yaml +27 -0
  134. package/v1/models/replicate.yaml +136 -0
  135. package/v1/models/sensenova.yaml +97 -0
  136. package/v1/models/siliconflow.yaml +29 -0
  137. package/v1/models/spark.yaml +114 -0
  138. package/v1/models/stable-diffusion.yaml +113 -0
  139. package/v1/models/tiangong.yaml +114 -0
  140. package/v1/models/together.yaml +29 -0
  141. package/v1/models/yi.yaml +132 -0
  142. package/v1/models/zhipu.yaml +163 -0
  143. package/v1/providers/ai21.yaml +176 -0
  144. package/v1/providers/anthropic.yaml +209 -0
  145. package/v1/providers/anyscale.yaml +106 -0
  146. package/v1/providers/azure.yaml +155 -0
  147. package/v1/providers/baichuan.yaml +168 -0
  148. package/v1/providers/baidu.yaml +173 -0
  149. package/v1/providers/cerebras.yaml +178 -0
  150. package/v1/providers/cohere.yaml +175 -0
  151. package/v1/providers/deepinfra.yaml +156 -0
  152. package/v1/providers/deepseek.yaml +189 -0
  153. package/v1/providers/doubao.yaml +172 -0
  154. package/v1/providers/fireworks.yaml +187 -0
  155. package/v1/providers/gemini.yaml +229 -0
  156. package/v1/providers/groq.yaml +181 -0
  157. package/v1/providers/huggingface.yaml +157 -0
  158. package/v1/providers/hunyuan.yaml +162 -0
  159. package/v1/providers/jina.yaml +171 -0
  160. package/v1/providers/lepton.yaml +183 -0
  161. package/v1/providers/minimax.yaml +172 -0
  162. package/v1/providers/mistral.yaml +186 -0
  163. package/v1/providers/moonshot.yaml +176 -0
  164. package/v1/providers/nvidia.yaml +172 -0
  165. package/v1/providers/openai.yaml +224 -0
  166. package/v1/providers/openrouter.yaml +181 -0
  167. package/v1/providers/perplexity.yaml +144 -0
  168. package/v1/providers/qwen.yaml +192 -0
  169. package/v1/providers/replicate.yaml +159 -0
  170. package/v1/providers/sensenova.yaml +153 -0
  171. package/v1/providers/siliconflow.yaml +156 -0
  172. package/v1/providers/spark.yaml +167 -0
  173. package/v1/providers/stability.yaml +185 -0
  174. package/v1/providers/tiangong.yaml +170 -0
  175. package/v1/providers/together.yaml +156 -0
  176. package/v1/providers/writer.yaml +212 -0
  177. package/v1/providers/xai.yaml +206 -0
  178. package/v1/providers/yi.yaml +168 -0
  179. package/v1/providers/zhipu.yaml +171 -0
  180. package/v1/spec.yaml +637 -0
  181. package/v2/providers/anthropic.yaml +244 -0
  182. package/v2/providers/cohere.yaml +75 -0
  183. package/v2/providers/deepseek.yaml +176 -0
  184. package/v2/providers/doubao.yaml +169 -0
  185. package/v2/providers/google.yaml +245 -0
  186. package/v2/providers/jina.yaml +55 -0
  187. package/v2/providers/moonshot.yaml +186 -0
  188. package/v2/providers/openai.yaml +266 -0
  189. package/v2/providers/qwen.yaml +174 -0
  190. package/v2/providers/zhipu.yaml +176 -0
  191. package/v2-alpha/providers/anthropic.yaml +134 -0
  192. package/v2-alpha/providers/gemini.yaml +144 -0
  193. package/v2-alpha/providers/openai.yaml +154 -0
  194. package/v2-alpha/spec.yaml +512 -0
@@ -0,0 +1,213 @@
1
+ {
2
+ "$schema": "https://raw.githubusercontent.com/ailib-official/ai-protocol/main/schemas/v1.json",
3
+ "id": "nvidia",
4
+ "protocol_version": "1.5",
5
+ "name": "NVIDIA API Catalog",
6
+ "version": "v1",
7
+ "status": "stable",
8
+ "category": "third_party_aggregator",
9
+ "official_url": "https://build.nvidia.com/explore/discover",
10
+ "support_contact": "https://docs.api.nvidia.com/nim/docs",
11
+ "endpoint": {
12
+ "base_url": "https://integrate.api.nvidia.com/v1",
13
+ "protocol": "https",
14
+ "timeout_ms": 60000
15
+ },
16
+ "auth": {
17
+ "type": "bearer",
18
+ "token_env": "NVIDIA_API_KEY"
19
+ },
20
+ "payload_format": "openai_style",
21
+ "api_families": [
22
+ "chat_completions",
23
+ "completions"
24
+ ],
25
+ "default_api_family": "chat_completions",
26
+ "endpoints": {
27
+ "chat": {
28
+ "path": "/chat/completions",
29
+ "method": "POST",
30
+ "adapter": "openai"
31
+ },
32
+ "completions": {
33
+ "path": "/completions",
34
+ "method": "POST",
35
+ "adapter": "openai"
36
+ }
37
+ },
38
+ "services": {
39
+ "list_models": {
40
+ "path": "/models",
41
+ "method": "GET",
42
+ "response_binding": "data"
43
+ }
44
+ },
45
+ "termination": {
46
+ "source_field": "finish_reason",
47
+ "mapping": {
48
+ "stop": "end_turn",
49
+ "length": "max_tokens",
50
+ "tool_calls": "tool_use",
51
+ "content_filter": "refusal"
52
+ },
53
+ "notes": [
54
+ "OpenAI-compatible: finish_reason is reported per candidate."
55
+ ]
56
+ },
57
+ "tooling": {
58
+ "source_model": "openai_tool_calls",
59
+ "tool_use": {
60
+ "id_path": "id",
61
+ "name_path": "function.name",
62
+ "input_path": "function.arguments",
63
+ "input_format": "json_string"
64
+ },
65
+ "notes": [
66
+ "OpenAI-compatible tool_calls.function.arguments is typically a JSON string."
67
+ ]
68
+ },
69
+ "retry_policy": {
70
+ "max_retries": 3,
71
+ "max_delay_ms": 30000,
72
+ "strategy": "exponential_backoff",
73
+ "min_delay_ms": 1000,
74
+ "jitter": "full",
75
+ "retry_on_http_status": [
76
+ 429,
77
+ 500,
78
+ 502,
79
+ 503
80
+ ],
81
+ "notes": [
82
+ "Exponential backoff recommended for 429; retry 5xx after brief wait."
83
+ ]
84
+ },
85
+ "error_classification": {
86
+ "by_http_status": {
87
+ "400": "invalid_request",
88
+ "401": "authentication",
89
+ "403": "permission_denied",
90
+ "404": "not_found",
91
+ "429": "rate_limited",
92
+ "500": "server_error"
93
+ }
94
+ },
95
+ "parameter_mappings": {
96
+ "temperature": "temperature",
97
+ "max_tokens": "max_tokens",
98
+ "stream": "stream",
99
+ "stop_sequences": "stop",
100
+ "tools": "tools",
101
+ "tool_choice": "tool_choice",
102
+ "frequency_penalty": "frequency_penalty",
103
+ "presence_penalty": "presence_penalty",
104
+ "top_p": "top_p"
105
+ },
106
+ "response_format": "openai_style",
107
+ "response_paths": {
108
+ "content": "choices[0].message.content",
109
+ "tool_calls": "choices[0].message.tool_calls",
110
+ "usage": "usage",
111
+ "finish_reason": "choices[0].finish_reason"
112
+ },
113
+ "streaming": {
114
+ "event_format": "data_lines",
115
+ "decoder": {
116
+ "format": "sse",
117
+ "delimiter": "\n\n",
118
+ "prefix": "data: ",
119
+ "done_signal": "[DONE]"
120
+ },
121
+ "content_path": "choices[0].delta.content",
122
+ "tool_call_path": "choices[0].delta.tool_calls",
123
+ "usage_path": "usage",
124
+ "frame_selector": "exists($.choices) || exists($.error)",
125
+ "event_map": [
126
+ {
127
+ "match": "exists($.choices[*].delta.content)",
128
+ "emit": "PartialContentDelta",
129
+ "fields": {
130
+ "content": "$.choices[*].delta.content"
131
+ }
132
+ },
133
+ {
134
+ "match": "exists($.choices[*].delta.tool_calls[*].function.name)",
135
+ "emit": "ToolCallStarted",
136
+ "fields": {
137
+ "tool_call_id": "$.choices[*].delta.tool_calls[*].id",
138
+ "tool_name": "$.choices[*].delta.tool_calls[*].function.name",
139
+ "index": "$.choices[*].delta.tool_calls[*].index"
140
+ }
141
+ },
142
+ {
143
+ "match": "exists($.choices[*].delta.tool_calls[*].function.arguments)",
144
+ "emit": "PartialToolCall",
145
+ "fields": {
146
+ "arguments": "$.choices[*].delta.tool_calls[*].function.arguments",
147
+ "index": "$.choices[*].delta.tool_calls[*].index"
148
+ }
149
+ },
150
+ {
151
+ "match": "exists($.usage)",
152
+ "emit": "Metadata",
153
+ "fields": {
154
+ "usage": "$.usage"
155
+ }
156
+ },
157
+ {
158
+ "match": "exists($.choices[*].finish_reason)",
159
+ "emit": "FinalCandidate",
160
+ "fields": {
161
+ "finish_reason": "$.choices[*].finish_reason",
162
+ "candidate_index": "$.choices[*].index"
163
+ }
164
+ }
165
+ ],
166
+ "stop_condition": "$.choices[0].finish_reason != null"
167
+ },
168
+ "features": {
169
+ "multi_candidate": {
170
+ "support_type": "native",
171
+ "param_name": "n"
172
+ },
173
+ "response_mapping": {
174
+ "tool_calls": {
175
+ "path": "choices[0].message.tool_calls",
176
+ "fields": {
177
+ "id": "id",
178
+ "name": "function.name",
179
+ "args": "function.arguments"
180
+ }
181
+ },
182
+ "error": {
183
+ "message_path": "error.message",
184
+ "code_path": "error.code",
185
+ "type_path": "error.type",
186
+ "param_path": "error.param"
187
+ }
188
+ }
189
+ },
190
+ "capabilities": {
191
+ "streaming": true,
192
+ "tools": true,
193
+ "vision": true,
194
+ "agentic": true,
195
+ "parallel_tools": true,
196
+ "reasoning": true
197
+ },
198
+ "availability": {
199
+ "required": false,
200
+ "regions": [
201
+ "global"
202
+ ],
203
+ "check": {
204
+ "method": "GET",
205
+ "path": "/models",
206
+ "expected_status": [
207
+ 200,
208
+ 401
209
+ ],
210
+ "timeout_ms": 5000
211
+ }
212
+ }
213
+ }
@@ -0,0 +1,267 @@
1
+ {
2
+ "$schema": "https://raw.githubusercontent.com/ailib-official/ai-protocol/main/schemas/v1.json",
3
+ "id": "openai",
4
+ "protocol_version": "1.5",
5
+ "name": "OpenAI",
6
+ "version": "v1",
7
+ "status": "stable",
8
+ "category": "ai_provider",
9
+ "official_url": "https://platform.openai.com/docs",
10
+ "support_contact": "https://help.openai.com",
11
+ "endpoint": {
12
+ "base_url": "https://api.openai.com/v1",
13
+ "protocol": "https",
14
+ "timeout_ms": 10000
15
+ },
16
+ "auth": {
17
+ "type": "bearer",
18
+ "token_env": "OPENAI_API_KEY"
19
+ },
20
+ "payload_format": "openai_style",
21
+ "api_families": [
22
+ "chat_completions",
23
+ "completions",
24
+ "assistants",
25
+ "realtime"
26
+ ],
27
+ "default_api_family": "chat_completions",
28
+ "endpoints": {
29
+ "chat": {
30
+ "path": "/chat/completions",
31
+ "method": "POST",
32
+ "adapter": "openai"
33
+ },
34
+ "completions": {
35
+ "path": "/completions",
36
+ "method": "POST",
37
+ "adapter": "openai"
38
+ },
39
+ "embeddings": {
40
+ "path": "/embeddings",
41
+ "method": "POST",
42
+ "adapter": "openai"
43
+ },
44
+ "realtime_ws": "wss://api.openai.com/v1/realtime"
45
+ },
46
+ "services": {
47
+ "list_models": {
48
+ "path": "/models",
49
+ "method": "GET",
50
+ "response_binding": "data"
51
+ },
52
+ "list_files": {
53
+ "path": "/files",
54
+ "method": "GET",
55
+ "response_binding": "data"
56
+ },
57
+ "create_batch": {
58
+ "path": "/batches",
59
+ "method": "POST"
60
+ }
61
+ },
62
+ "termination": {
63
+ "source_field": "finish_reason",
64
+ "mapping": {
65
+ "stop": "end_turn",
66
+ "length": "max_tokens",
67
+ "tool_calls": "tool_use",
68
+ "content_filter": "refusal"
69
+ },
70
+ "notes": [
71
+ "finish_reason is reported per candidate."
72
+ ]
73
+ },
74
+ "tooling": {
75
+ "source_model": "openai_tool_calls",
76
+ "tool_use": {
77
+ "id_path": "id",
78
+ "name_path": "function.name",
79
+ "input_path": "function.arguments",
80
+ "input_format": "json_string"
81
+ },
82
+ "notes": [
83
+ "OpenAI tool_calls.function.arguments is typically a JSON string; runtimes SHOULD parse it into an object when normalizing to tool_use.input."
84
+ ]
85
+ },
86
+ "rate_limit_headers": {
87
+ "requests_limit": "x-ratelimit-limit-requests",
88
+ "tokens_limit": "x-ratelimit-limit-tokens",
89
+ "requests_remaining": "x-ratelimit-remaining-requests",
90
+ "tokens_remaining": "x-ratelimit-remaining-tokens",
91
+ "requests_reset": "x-ratelimit-reset-requests",
92
+ "tokens_reset": "x-ratelimit-reset-tokens"
93
+ },
94
+ "retry_policy": {
95
+ "max_retries": 3,
96
+ "max_delay_ms": 30000,
97
+ "strategy": "exponential_backoff",
98
+ "min_delay_ms": 1000,
99
+ "jitter": "full",
100
+ "retry_on_http_status": [
101
+ 429,
102
+ 500,
103
+ 502,
104
+ 503
105
+ ],
106
+ "notes": [
107
+ "429 may be rate limit reached OR quota exhausted; runtimes SHOULD avoid retrying quota-exhausted cases when detectable (e.g., via error message).",
108
+ "For rate limit errors, exponential backoff is recommended.",
109
+ "For 500 server errors, retry after a brief wait."
110
+ ]
111
+ },
112
+ "error_classification": {
113
+ "by_http_status": {
114
+ "400": "invalid_request",
115
+ "401": "authentication",
116
+ "403": "permission_denied",
117
+ "404": "not_found",
118
+ "429": "rate_limited",
119
+ "500": "server_error"
120
+ },
121
+ "notes": [
122
+ "OpenAI 429 may also indicate quota/billing exhaustion; runtimes SHOULD treat it as quota_exhausted when the message indicates plan/billing/quota."
123
+ ]
124
+ },
125
+ "parameter_mappings": {
126
+ "temperature": "temperature",
127
+ "max_tokens": "max_tokens",
128
+ "stream": "stream",
129
+ "top_p": "top_p",
130
+ "stop_sequences": "stop",
131
+ "frequency_penalty": "frequency_penalty",
132
+ "presence_penalty": "presence_penalty",
133
+ "logprobs": "logprobs",
134
+ "top_logprobs": "top_logprobs",
135
+ "seed": "seed",
136
+ "tools": "tools",
137
+ "tool_choice": "tool_choice",
138
+ "reasoning_effort": "reasoning_effort"
139
+ },
140
+ "response_format": "openai_style",
141
+ "response_paths": {
142
+ "content": "choices[0].message.content",
143
+ "tool_calls": "choices[0].message.tool_calls",
144
+ "usage": "usage",
145
+ "finish_reason": "choices[0].finish_reason"
146
+ },
147
+ "streaming": {
148
+ "event_format": "data_lines",
149
+ "decoder": {
150
+ "format": "sse",
151
+ "delimiter": "\n\n",
152
+ "prefix": "data: ",
153
+ "done_signal": "[DONE]"
154
+ },
155
+ "frame_selector": "exists($.choices) || exists($.error) || $.type == 'error'",
156
+ "candidate": {
157
+ "candidate_id_path": "$.choices[*].index",
158
+ "fan_out": true
159
+ },
160
+ "event_map": [
161
+ {
162
+ "match": "exists($.error) || $.type == 'error'",
163
+ "emit": "StreamError",
164
+ "fields": {
165
+ "type": "$.type",
166
+ "event_id": "$.event_id",
167
+ "error": "$.error"
168
+ }
169
+ },
170
+ {
171
+ "match": "exists($.choices[*].delta.content)",
172
+ "emit": "PartialContentDelta",
173
+ "fields": {
174
+ "content": "$.choices[*].delta.content"
175
+ }
176
+ },
177
+ {
178
+ "match": "exists($.choices[*].delta.tool_calls[*].function.name)",
179
+ "emit": "ToolCallStarted",
180
+ "fields": {
181
+ "tool_call_id": "$.choices[*].delta.tool_calls[*].id",
182
+ "tool_name": "$.choices[*].delta.tool_calls[*].function.name",
183
+ "index": "$.choices[*].delta.tool_calls[*].index"
184
+ }
185
+ },
186
+ {
187
+ "match": "exists($.choices[*].delta.tool_calls[*].function.arguments)",
188
+ "emit": "PartialToolCall",
189
+ "fields": {
190
+ "arguments": "$.choices[*].delta.tool_calls[*].function.arguments",
191
+ "index": "$.choices[*].delta.tool_calls[*].index"
192
+ }
193
+ },
194
+ {
195
+ "match": "exists($.usage)",
196
+ "emit": "Metadata",
197
+ "fields": {
198
+ "usage": "$.usage",
199
+ "prompt_tokens": "$.usage.prompt_tokens",
200
+ "completion_tokens": "$.usage.completion_tokens"
201
+ }
202
+ },
203
+ {
204
+ "match": "exists($.choices[*].finish_reason)",
205
+ "emit": "FinalCandidate",
206
+ "fields": {
207
+ "finish_reason": "$.choices[*].finish_reason",
208
+ "candidate_index": "$.choices[*].index"
209
+ }
210
+ }
211
+ ],
212
+ "stop_condition": "$.choices[0].finish_reason != null",
213
+ "extra_metadata_path": "$.usage",
214
+ "content_path": "choices[0].delta.content",
215
+ "tool_call_path": "choices[0].delta.tool_calls"
216
+ },
217
+ "features": {
218
+ "multi_candidate": {
219
+ "support_type": "native",
220
+ "param_name": "n"
221
+ },
222
+ "response_mapping": {
223
+ "tool_calls": {
224
+ "path": "choices[0].message.tool_calls",
225
+ "fields": {
226
+ "id": "id",
227
+ "name": "function.name",
228
+ "args": "function.arguments"
229
+ }
230
+ },
231
+ "error": {
232
+ "message_path": "error.message",
233
+ "code_path": "error.code",
234
+ "type_path": "error.type",
235
+ "param_path": "error.param"
236
+ }
237
+ }
238
+ },
239
+ "capabilities": {
240
+ "streaming": true,
241
+ "tools": true,
242
+ "vision": true,
243
+ "agentic": true,
244
+ "parallel_tools": true,
245
+ "reasoning": true
246
+ },
247
+ "experimental_features": [
248
+ "strict_tools",
249
+ "parallel_tool_calls",
250
+ "responses_api"
251
+ ],
252
+ "availability": {
253
+ "required": false,
254
+ "regions": [
255
+ "global"
256
+ ],
257
+ "check": {
258
+ "method": "GET",
259
+ "path": "/models",
260
+ "expected_status": [
261
+ 200,
262
+ 401
263
+ ],
264
+ "timeout_ms": 3000
265
+ }
266
+ }
267
+ }
@@ -0,0 +1,220 @@
1
+ {
2
+ "$schema": "https://raw.githubusercontent.com/ailib-official/ai-protocol/main/schemas/v1.json",
3
+ "id": "openrouter",
4
+ "protocol_version": "1.5",
5
+ "name": "OpenRouter",
6
+ "version": "v1",
7
+ "status": "stable",
8
+ "category": "third_party_aggregator",
9
+ "official_url": "https://openrouter.ai/docs",
10
+ "support_contact": "https://openrouter.ai/contact",
11
+ "endpoint": {
12
+ "base_url": "https://openrouter.ai/api/v1",
13
+ "protocol": "https",
14
+ "timeout_ms": 120000
15
+ },
16
+ "auth": {
17
+ "type": "bearer",
18
+ "token_env": "OPENROUTER_API_KEY"
19
+ },
20
+ "payload_format": "openai_style",
21
+ "api_families": [
22
+ "chat_completions"
23
+ ],
24
+ "default_api_family": "chat_completions",
25
+ "endpoints": {
26
+ "chat": {
27
+ "path": "/chat/completions",
28
+ "method": "POST",
29
+ "adapter": "openai"
30
+ }
31
+ },
32
+ "services": {
33
+ "list_models": {
34
+ "path": "/models",
35
+ "method": "GET",
36
+ "response_binding": "data"
37
+ },
38
+ "get_generation": {
39
+ "path": "/generation",
40
+ "method": "GET"
41
+ }
42
+ },
43
+ "termination": {
44
+ "source_field": "finish_reason",
45
+ "mapping": {
46
+ "stop": "end_turn",
47
+ "length": "max_tokens",
48
+ "tool_calls": "tool_use",
49
+ "content_filter": "refusal"
50
+ },
51
+ "notes": [
52
+ "OpenRouter normalizes responses to OpenAI format.",
53
+ "Aggregates 100+ models from various providers."
54
+ ]
55
+ },
56
+ "tooling": {
57
+ "source_model": "openai_tool_calls",
58
+ "tool_use": {
59
+ "id_path": "id",
60
+ "name_path": "function.name",
61
+ "input_path": "function.arguments",
62
+ "input_format": "json_string"
63
+ },
64
+ "notes": [
65
+ "Tool support depends on underlying model."
66
+ ]
67
+ },
68
+ "retry_policy": {
69
+ "strategy": "exponential_backoff",
70
+ "max_retries": 3,
71
+ "min_delay_ms": 1000,
72
+ "max_delay_ms": 60000,
73
+ "jitter": "full",
74
+ "retry_on_http_status": [
75
+ 429,
76
+ 500,
77
+ 502,
78
+ 503
79
+ ],
80
+ "notes": [
81
+ "OpenRouter may have longer latencies due to routing."
82
+ ]
83
+ },
84
+ "error_classification": {
85
+ "by_http_status": {
86
+ "400": "invalid_request",
87
+ "401": "authentication",
88
+ "402": "quota_exhausted",
89
+ "403": "permission_denied",
90
+ "404": "not_found",
91
+ "429": "rate_limited",
92
+ "500": "server_error",
93
+ "502": "server_error",
94
+ "503": "overloaded"
95
+ }
96
+ },
97
+ "parameter_mappings": {
98
+ "temperature": "temperature",
99
+ "max_tokens": "max_tokens",
100
+ "stream": "stream",
101
+ "top_p": "top_p",
102
+ "frequency_penalty": "frequency_penalty",
103
+ "presence_penalty": "presence_penalty",
104
+ "stop_sequences": "stop",
105
+ "tools": "tools",
106
+ "tool_choice": "tool_choice",
107
+ "seed": "seed",
108
+ "top_k": "top_k"
109
+ },
110
+ "response_format": "openai_style",
111
+ "response_paths": {
112
+ "content": "choices[0].message.content",
113
+ "tool_calls": "choices[0].message.tool_calls",
114
+ "usage": "usage",
115
+ "finish_reason": "choices[0].finish_reason"
116
+ },
117
+ "streaming": {
118
+ "event_format": "data_lines",
119
+ "decoder": {
120
+ "format": "sse",
121
+ "delimiter": "\n\n",
122
+ "prefix": "data: ",
123
+ "done_signal": "[DONE]"
124
+ },
125
+ "content_path": "choices[0].delta.content",
126
+ "tool_call_path": "choices[0].delta.tool_calls",
127
+ "usage_path": "usage",
128
+ "frame_selector": "exists($.choices) || exists($.error)",
129
+ "event_map": [
130
+ {
131
+ "match": "exists($.choices[*].delta.content)",
132
+ "emit": "PartialContentDelta",
133
+ "fields": {
134
+ "content": "$.choices[*].delta.content"
135
+ }
136
+ },
137
+ {
138
+ "match": "exists($.choices[*].delta.tool_calls[*].function.name)",
139
+ "emit": "ToolCallStarted",
140
+ "fields": {
141
+ "tool_call_id": "$.choices[*].delta.tool_calls[*].id",
142
+ "tool_name": "$.choices[*].delta.tool_calls[*].function.name",
143
+ "index": "$.choices[*].delta.tool_calls[*].index"
144
+ }
145
+ },
146
+ {
147
+ "match": "exists($.choices[*].delta.tool_calls[*].function.arguments)",
148
+ "emit": "PartialToolCall",
149
+ "fields": {
150
+ "arguments": "$.choices[*].delta.tool_calls[*].function.arguments",
151
+ "index": "$.choices[*].delta.tool_calls[*].index"
152
+ }
153
+ },
154
+ {
155
+ "match": "exists($.usage)",
156
+ "emit": "Metadata",
157
+ "fields": {
158
+ "usage": "$.usage"
159
+ }
160
+ },
161
+ {
162
+ "match": "exists($.choices[*].finish_reason)",
163
+ "emit": "FinalCandidate",
164
+ "fields": {
165
+ "finish_reason": "$.choices[*].finish_reason"
166
+ }
167
+ }
168
+ ],
169
+ "stop_condition": "$.choices[0].finish_reason != null"
170
+ },
171
+ "features": {
172
+ "multi_candidate": {
173
+ "support_type": "native",
174
+ "param_name": "n"
175
+ },
176
+ "response_mapping": {
177
+ "tool_calls": {
178
+ "path": "choices[0].message.tool_calls",
179
+ "fields": {
180
+ "id": "id",
181
+ "name": "function.name",
182
+ "args": "function.arguments"
183
+ }
184
+ },
185
+ "error": {
186
+ "message_path": "error.message",
187
+ "code_path": "error.code",
188
+ "type_path": "error.type"
189
+ }
190
+ }
191
+ },
192
+ "capabilities": {
193
+ "streaming": true,
194
+ "tools": true,
195
+ "vision": true,
196
+ "agentic": true,
197
+ "parallel_tools": true,
198
+ "reasoning": true
199
+ },
200
+ "availability": {
201
+ "required": false,
202
+ "regions": [
203
+ "global"
204
+ ],
205
+ "check": {
206
+ "method": "GET",
207
+ "path": "/models",
208
+ "expected_status": [
209
+ 200,
210
+ 401
211
+ ],
212
+ "timeout_ms": 5000
213
+ }
214
+ },
215
+ "experimental_features": [
216
+ "model_routing",
217
+ "fallback_models",
218
+ "cost_tracking"
219
+ ]
220
+ }