@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,279 @@
1
+ {
2
+ "$schema": "https://raw.githubusercontent.com/ailib-official/ai-protocol/main/schemas/v1.json",
3
+ "id": "gemini",
4
+ "protocol_version": "1.5",
5
+ "name": "Google Gemini",
6
+ "version": "v1beta",
7
+ "status": "stable",
8
+ "category": "ai_provider",
9
+ "official_url": "https://ai.google.dev/docs",
10
+ "support_contact": "https://support.google.com/gemini",
11
+ "endpoint": {
12
+ "base_url": "https://generativelanguage.googleapis.com/v1beta",
13
+ "protocol": "https",
14
+ "timeout_ms": 10000
15
+ },
16
+ "auth": {
17
+ "type": "query_param",
18
+ "param_name": "key",
19
+ "token_env": "GEMINI_API_KEY"
20
+ },
21
+ "payload_format": "gemini_style",
22
+ "api_families": [
23
+ "generate_content"
24
+ ],
25
+ "default_api_family": "generate_content",
26
+ "endpoints": {
27
+ "chat": {
28
+ "path": "/models/{model}:generateContent",
29
+ "method": "POST",
30
+ "adapter": "gemini"
31
+ }
32
+ },
33
+ "services": {
34
+ "list_models": {
35
+ "path": "/models",
36
+ "method": "GET",
37
+ "response_binding": "models"
38
+ },
39
+ "list_files": {
40
+ "path": "/files",
41
+ "method": "GET",
42
+ "response_binding": "files"
43
+ },
44
+ "get_model": {
45
+ "path": "/models/{model}",
46
+ "method": "GET"
47
+ }
48
+ },
49
+ "termination": {
50
+ "source_field": "finishReason",
51
+ "mapping": {
52
+ "FINISH_REASON_UNSPECIFIED": "other",
53
+ "STOP": "end_turn",
54
+ "MAX_TOKENS": "max_tokens",
55
+ "SAFETY": "refusal",
56
+ "RECITATION": "refusal",
57
+ "LANGUAGE": "refusal",
58
+ "OTHER": "other",
59
+ "BLOCKLIST": "refusal",
60
+ "PROHIBITED_CONTENT": "refusal",
61
+ "SPII": "refusal",
62
+ "MALFORMED_FUNCTION_CALL": "other",
63
+ "IMAGE_SAFETY": "refusal",
64
+ "IMAGE_PROHIBITED_CONTENT": "refusal",
65
+ "IMAGE_OTHER": "other",
66
+ "NO_IMAGE": "other",
67
+ "IMAGE_RECITATION": "refusal",
68
+ "UNEXPECTED_TOOL_CALL": "other",
69
+ "TOO_MANY_TOOL_CALLS": "other",
70
+ "MISSING_THOUGHT_SIGNATURE": "other"
71
+ },
72
+ "notes": [
73
+ "finishReason enum is VERIFIED in research/providers/gemini.md (from official generate-content reference).",
74
+ "STOP covers both natural stop and provided stop sequence; this mapping chooses end_turn because stop_sequence cannot be distinguished from finishReason alone."
75
+ ]
76
+ },
77
+ "tooling": {
78
+ "source_model": "gemini_function_call",
79
+ "tool_use": {
80
+ "name_path": "functionCall.name",
81
+ "input_path": "functionCall.args",
82
+ "input_format": "json_object"
83
+ },
84
+ "tool_result": {
85
+ "id_path": "functionResponse.id",
86
+ "name_path": "functionResponse.name",
87
+ "response_path": "functionResponse.response",
88
+ "output_path": "functionResponse.response.output",
89
+ "error_path": "functionResponse.response.error",
90
+ "format": "json_object"
91
+ },
92
+ "notes": [
93
+ "Gemini represents tool invocations via functionCall in content parts; normalization to tool_use/tool_result should follow the runtime's part-parsing logic."
94
+ ]
95
+ },
96
+ "retry_policy": {
97
+ "strategy": "exponential_backoff",
98
+ "max_retries": 2,
99
+ "min_delay_ms": 1000,
100
+ "max_delay_ms": 8000,
101
+ "jitter": "full",
102
+ "retry_on_http_status": [
103
+ 429,
104
+ 503,
105
+ 504
106
+ ],
107
+ "retry_on_error_status": [
108
+ "RESOURCE_EXHAUSTED",
109
+ "UNAVAILABLE",
110
+ "DEADLINE_EXCEEDED"
111
+ ],
112
+ "notes": [
113
+ "On 429/RESOURCE_EXHAUSTED: retry after a few seconds; recommend no more than two retries; min 1s with exponential backoff."
114
+ ]
115
+ },
116
+ "error_classification": {
117
+ "by_http_status": {
118
+ "400": "invalid_request",
119
+ "403": "permission_denied",
120
+ "404": "not_found",
121
+ "429": "rate_limited",
122
+ "499": "cancelled",
123
+ "500": "server_error",
124
+ "503": "overloaded",
125
+ "504": "timeout"
126
+ },
127
+ "by_error_status": {
128
+ "INVALID_ARGUMENT": "invalid_request",
129
+ "FAILED_PRECONDITION": "invalid_request",
130
+ "PERMISSION_DENIED": "permission_denied",
131
+ "NOT_FOUND": "not_found",
132
+ "RESOURCE_EXHAUSTED": "rate_limited",
133
+ "CANCELLED": "cancelled",
134
+ "UNKNOWN": "server_error",
135
+ "INTERNAL": "server_error",
136
+ "UNAVAILABLE": "overloaded",
137
+ "DEADLINE_EXCEEDED": "timeout"
138
+ },
139
+ "notes": [
140
+ "Vertex/Gemini follows the Google Cloud API error model; prefer mapping by canonical error.status when present."
141
+ ]
142
+ },
143
+ "parameter_mappings": {
144
+ "temperature": "generationConfig.temperature",
145
+ "max_tokens": "generationConfig.maxOutputTokens",
146
+ "top_p": "generationConfig.topP",
147
+ "top_k": "generationConfig.topK",
148
+ "stop_sequences": "stopSequences",
149
+ "tools": "tools",
150
+ "tool_choice": "toolConfig"
151
+ },
152
+ "response_format": "gemini_style",
153
+ "response_paths": {
154
+ "content": "candidates[0].content.parts[0].text",
155
+ "tool_calls": "candidates[0].content.parts[0].functionCall",
156
+ "usage": "usageMetadata",
157
+ "finish_reason": "candidates[0].finishReason"
158
+ },
159
+ "streaming": {
160
+ "event_format": "sse_data_lines",
161
+ "decoder": {
162
+ "format": "sse",
163
+ "delimiter": "\n\n",
164
+ "prefix": "data: "
165
+ },
166
+ "frame_selector": "exists($.candidates) || exists($.error)",
167
+ "candidate": {
168
+ "candidate_id_path": "$.candidates[*].index",
169
+ "fan_out": true
170
+ },
171
+ "event_map": [
172
+ {
173
+ "match": "exists($.error)",
174
+ "emit": "StreamError",
175
+ "fields": {
176
+ "error": "$.error",
177
+ "model_version": "$.modelVersion"
178
+ }
179
+ },
180
+ {
181
+ "match": "exists($.candidates[*].content.parts[*].text)",
182
+ "emit": "PartialContentDelta",
183
+ "fields": {
184
+ "content": "$.candidates[*].content.parts[*].text"
185
+ }
186
+ },
187
+ {
188
+ "match": "exists($.candidates[*].content.parts[*].functionCall.name)",
189
+ "emit": "ToolCallStarted",
190
+ "fields": {
191
+ "tool_name": "$.candidates[*].content.parts[*].functionCall.name",
192
+ "tool_call_id": "_generate_uuid"
193
+ }
194
+ },
195
+ {
196
+ "match": "exists($.candidates[*].content.parts[*].functionCall.args)",
197
+ "emit": "PartialToolCall",
198
+ "fields": {
199
+ "arguments": "$.candidates[*].content.parts[*].functionCall.args",
200
+ "tool_name": "$.candidates[*].content.parts[*].functionCall.name",
201
+ "tool_call_id": "_generate_uuid"
202
+ }
203
+ },
204
+ {
205
+ "match": "exists($.usageMetadata)",
206
+ "emit": "Metadata",
207
+ "fields": {
208
+ "usage": "$.usageMetadata",
209
+ "prompt_tokens": "$.usageMetadata.promptTokenCount",
210
+ "completion_tokens": "$.usageMetadata.candidatesTokenCount"
211
+ }
212
+ },
213
+ {
214
+ "match": "exists($.candidates[*].finishReason)",
215
+ "emit": "FinalCandidate",
216
+ "fields": {
217
+ "finish_reason": "$.candidates[*].finishReason",
218
+ "candidate_index": "$.candidates[*].index"
219
+ }
220
+ }
221
+ ],
222
+ "stop_condition": "exists($.candidates[*].finishReason)",
223
+ "extra_metadata_path": "$.usageMetadata",
224
+ "content_path": "candidates[0].content.parts[0].text",
225
+ "tool_call_path": "candidates[0].content.parts[0].functionCall.args"
226
+ },
227
+ "features": {
228
+ "multi_candidate": {
229
+ "support_type": "native",
230
+ "param_name": "candidateCount"
231
+ },
232
+ "response_mapping": {
233
+ "tool_calls": {
234
+ "path": "candidates[0].content.parts",
235
+ "filter": "exists(functionCall)",
236
+ "fields": {
237
+ "id": "_generate_uuid",
238
+ "name": "functionCall.name",
239
+ "args": "functionCall.args",
240
+ "id_strategy": "generate_uuid"
241
+ },
242
+ "array_fan_out": true
243
+ },
244
+ "error": {
245
+ "message_path": "error.message",
246
+ "code_path": "error.code",
247
+ "status_path": "error.status",
248
+ "errors_path": "error.errors"
249
+ }
250
+ }
251
+ },
252
+ "capabilities": {
253
+ "streaming": true,
254
+ "tools": true,
255
+ "vision": true,
256
+ "agentic": false,
257
+ "parallel_tools": false,
258
+ "reasoning": false
259
+ },
260
+ "availability": {
261
+ "required": false,
262
+ "regions": [
263
+ "global"
264
+ ],
265
+ "check": {
266
+ "method": "GET",
267
+ "path": "/models",
268
+ "expected_status": [
269
+ 200,
270
+ 401
271
+ ],
272
+ "timeout_ms": 3000
273
+ }
274
+ },
275
+ "experimental_features": [
276
+ "multimodal_video",
277
+ "multimodal_audio"
278
+ ]
279
+ }
@@ -0,0 +1,218 @@
1
+ {
2
+ "$schema": "https://raw.githubusercontent.com/ailib-official/ai-protocol/main/schemas/v1.json",
3
+ "id": "groq",
4
+ "protocol_version": "1.5",
5
+ "name": "Groq",
6
+ "version": "v1",
7
+ "status": "stable",
8
+ "category": "ai_provider",
9
+ "official_url": "https://console.groq.com/docs",
10
+ "support_contact": "https://support.groq.com",
11
+ "endpoint": {
12
+ "base_url": "https://api.groq.com/openai/v1",
13
+ "protocol": "https",
14
+ "timeout_ms": 10000
15
+ },
16
+ "auth": {
17
+ "type": "bearer",
18
+ "token_env": "GROQ_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; runtimes SHOULD parse it into an object when normalizing."
67
+ ]
68
+ },
69
+ "rate_limit_headers": {
70
+ "requests_limit": "x-ratelimit-limit-requests",
71
+ "requests_remaining": "x-ratelimit-remaining-requests",
72
+ "requests_reset": "x-ratelimit-reset-requests",
73
+ "tokens_limit": "x-ratelimit-limit-tokens",
74
+ "tokens_remaining": "x-ratelimit-remaining-tokens",
75
+ "tokens_reset": "x-ratelimit-reset-tokens",
76
+ "retry_after": "retry-after"
77
+ },
78
+ "retry_policy": {
79
+ "max_retries": 3,
80
+ "max_delay_ms": 30000,
81
+ "strategy": "exponential_backoff",
82
+ "min_delay_ms": 1000,
83
+ "jitter": "full",
84
+ "retry_on_http_status": [
85
+ 429,
86
+ 500,
87
+ 502,
88
+ 503
89
+ ],
90
+ "notes": [
91
+ "OpenAI-compatible: exponential backoff is recommended for rate limit errors (429).",
92
+ "Retry 500 after a brief wait."
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
+ "logprobs": "logprobs",
105
+ "top_logprobs": "top_logprobs",
106
+ "seed": "seed"
107
+ },
108
+ "response_format": "openai_style",
109
+ "response_paths": {
110
+ "content": "choices[0].message.content",
111
+ "tool_calls": "choices[0].message.tool_calls",
112
+ "usage": "usage"
113
+ },
114
+ "streaming": {
115
+ "event_format": "data_lines",
116
+ "decoder": {
117
+ "format": "sse",
118
+ "delimiter": "\n\n",
119
+ "prefix": "data: ",
120
+ "done_signal": "[DONE]"
121
+ },
122
+ "content_path": "choices[0].delta.content",
123
+ "tool_call_path": "choices[0].delta.tool_calls",
124
+ "usage_path": "usage",
125
+ "frame_selector": "exists($.choices) || exists($.error)",
126
+ "event_map": [
127
+ {
128
+ "match": "exists($.choices[*].delta.content)",
129
+ "emit": "PartialContentDelta",
130
+ "fields": {
131
+ "content": "$.choices[*].delta.content"
132
+ }
133
+ },
134
+ {
135
+ "match": "exists($.choices[*].delta.tool_calls[*].function.name)",
136
+ "emit": "ToolCallStarted",
137
+ "fields": {
138
+ "tool_call_id": "$.choices[*].delta.tool_calls[*].id",
139
+ "tool_name": "$.choices[*].delta.tool_calls[*].function.name",
140
+ "index": "$.choices[*].delta.tool_calls[*].index"
141
+ }
142
+ },
143
+ {
144
+ "match": "exists($.choices[*].delta.tool_calls[*].function.arguments)",
145
+ "emit": "PartialToolCall",
146
+ "fields": {
147
+ "arguments": "$.choices[*].delta.tool_calls[*].function.arguments",
148
+ "index": "$.choices[*].delta.tool_calls[*].index"
149
+ }
150
+ },
151
+ {
152
+ "match": "exists($.usage)",
153
+ "emit": "Metadata",
154
+ "fields": {
155
+ "usage": "$.usage"
156
+ }
157
+ },
158
+ {
159
+ "match": "$.choices[*].finish_reason != null",
160
+ "emit": "StreamEnd",
161
+ "fields": {
162
+ "finish_reason": "$.choices[*].finish_reason"
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": false,
194
+ "agentic": true,
195
+ "parallel_tools": true,
196
+ "reasoning": false
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": 3000
211
+ }
212
+ },
213
+ "experimental_features": [
214
+ "builtin_search",
215
+ "code_execution",
216
+ "fast_inference"
217
+ ]
218
+ }
@@ -0,0 +1,181 @@
1
+ {
2
+ "$schema": "https://raw.githubusercontent.com/ailib-official/ai-protocol/main/schemas/v1.json",
3
+ "id": "huggingface",
4
+ "protocol_version": "1.5",
5
+ "name": "Hugging Face Inference",
6
+ "version": "v1",
7
+ "status": "stable",
8
+ "category": "model_provider",
9
+ "official_url": "https://huggingface.co/docs/api-inference",
10
+ "support_contact": "https://huggingface.co/support",
11
+ "endpoint": {
12
+ "base_url": "https://api-inference.huggingface.co/models",
13
+ "protocol": "https",
14
+ "timeout_ms": 60000
15
+ },
16
+ "auth": {
17
+ "type": "bearer",
18
+ "token_env": "HUGGINGFACE_API_KEY",
19
+ "payload_format": "inference_api"
20
+ },
21
+ "api_families": [
22
+ "text_generation",
23
+ "image_generation",
24
+ "embeddings",
25
+ "audio"
26
+ ],
27
+ "default_api_family": "text_generation",
28
+ "endpoints": {
29
+ "chat": {
30
+ "path": "/{model_id}",
31
+ "method": "POST",
32
+ "adapter": "huggingface"
33
+ },
34
+ "embeddings": {
35
+ "path": "/{model_id}",
36
+ "method": "POST",
37
+ "adapter": "huggingface"
38
+ },
39
+ "image": {
40
+ "path": "/{model_id}",
41
+ "method": "POST",
42
+ "adapter": "huggingface"
43
+ }
44
+ },
45
+ "services": {
46
+ "list_models": {
47
+ "path": "https://huggingface.co/api/models",
48
+ "method": "GET",
49
+ "response_binding": "null"
50
+ }
51
+ },
52
+ "termination": {
53
+ "source_field": "finish_reason",
54
+ "mapping": {
55
+ "stop": "end_turn",
56
+ "length": "max_tokens"
57
+ },
58
+ "notes": [
59
+ "finish_reason varies by model",
60
+ "not all models support explicit finish_reason"
61
+ ]
62
+ },
63
+ "tooling": {
64
+ "source_model": "unknown",
65
+ "notes": [
66
+ "Hugging Face serverless inference does not natively support tool calling",
67
+ "Deployed custom models may implement tool calling via custom logic"
68
+ ]
69
+ },
70
+ "retry_policy": {
71
+ "strategy": "exponential_backoff",
72
+ "max_retries": 3,
73
+ "min_delay_ms": 1000,
74
+ "max_delay_ms": 10000,
75
+ "jitter": "full",
76
+ "retry_on_http_status": [
77
+ 429,
78
+ 500,
79
+ 502,
80
+ 503
81
+ ],
82
+ "notes": [
83
+ "Hugging Face free tier has cold starts; retry recommended",
84
+ "503 is common during model loading"
85
+ ]
86
+ },
87
+ "error_classification": {
88
+ "by_http_status": {
89
+ "400": "invalid_request",
90
+ "401": "authentication",
91
+ "403": "permission_denied",
92
+ "404": "not_found",
93
+ "429": "rate_limited",
94
+ "500": "server_error",
95
+ "503": "overloaded"
96
+ },
97
+ "notes": [
98
+ "503 often indicates model is loading (cold start)",
99
+ "404 may indicate model not found or removed"
100
+ ]
101
+ },
102
+ "parameter_mappings": {
103
+ "temperature": "temperature",
104
+ "max_tokens": "max_new_tokens",
105
+ "stream": "stream",
106
+ "top_p": "top_p",
107
+ "stop_sequences": "stop",
108
+ "top_k": "top_k",
109
+ "repetition_penalty": "repetition_penalty"
110
+ },
111
+ "response_format": "huggingface_style",
112
+ "response_paths": {
113
+ "content": "output_text",
114
+ "generated_text": "generated_text",
115
+ "usage": "details"
116
+ },
117
+ "streaming": {
118
+ "event_format": "inference_api",
119
+ "decoder": {
120
+ "format": "sse",
121
+ "delimiter": "\n",
122
+ "prefix": "",
123
+ "done_signal": ""
124
+ },
125
+ "frame_selector": "exists($.token) || exists($.generated_text)",
126
+ "event_map": [
127
+ {
128
+ "match": "exists($.token)",
129
+ "emit": "PartialContentDelta",
130
+ "fields": {
131
+ "content": "$.token.text",
132
+ "token_id": "$.token.id"
133
+ }
134
+ },
135
+ {
136
+ "match": "exists($.generated_text)",
137
+ "emit": "FinalCandidate",
138
+ "fields": {
139
+ "content": "$.generated_text"
140
+ }
141
+ }
142
+ ],
143
+ "stop_condition": "exists($.finish_reason) || length > 0 && !exists($.token)",
144
+ "extra_metadata_path": "$.details",
145
+ "content_path": "$.output_text"
146
+ },
147
+ "capabilities": {
148
+ "streaming": true,
149
+ "tools": false,
150
+ "vision": true,
151
+ "agentic": false,
152
+ "parallel_tools": false,
153
+ "reasoning": false
154
+ },
155
+ "experimental_features": [
156
+ "model_selection",
157
+ "serverless_inference",
158
+ "custom_deployment"
159
+ ],
160
+ "connection_vars": {
161
+ "model_id": "model"
162
+ },
163
+ "availability": {
164
+ "required": false,
165
+ "regions": [
166
+ "global"
167
+ ],
168
+ "check": {
169
+ "method": "GET",
170
+ "path": "/meta-llama/Llama-2-7b-chat-hf",
171
+ "expected_status": [
172
+ 200
173
+ ],
174
+ "timeout_ms": 5000
175
+ },
176
+ "notes": [
177
+ "Check against a popular model (Llama-2) to verify service availability",
178
+ "Model-specific endpoint: /models/{model_id}"
179
+ ]
180
+ }
181
+ }