@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,155 @@
1
+ # AI-Protocol Provider Manifest for Azure OpenAI
2
+ $schema: "https://raw.githubusercontent.com/ailib-official/ai-protocol/main/schemas/v1.json"
3
+ id: azure
4
+ protocol_version: "1.5"
5
+
6
+ # Azure URLs are highly dynamic: https://{resource}.openai.azure.com/openai/deployments/{deployment}/chat/completions?api-version={version}
7
+ # This manifest serves as a template. The runtime's `HttpTransport` should support variable injection
8
+ # or the user should configure the `base_url` explicitly in their overlay config.
9
+ endpoint:
10
+ base_url: "https://${AZURE_RESOURCE_NAME}.openai.azure.com/openai/deployments/${AZURE_DEPLOYMENT_ID}"
11
+ protocol: "https"
12
+ timeout_ms: 30000
13
+
14
+ availability:
15
+ required: true
16
+ regions: ["global"]
17
+ check:
18
+ method: "GET"
19
+ path: "/models?api-version=2024-02-01"
20
+ expected_status: [200]
21
+
22
+ capabilities:
23
+ streaming: true
24
+ tools: true
25
+ vision: true
26
+
27
+ auth:
28
+ type: "api_key"
29
+ key_env: "AZURE_OPENAI_KEY"
30
+ header_name: "api-key"
31
+ # Azure also supports Active Directory via "Authorization: Bearer <token>",
32
+ # but api-key is the standard for simple integrations.
33
+
34
+ parameter_mappings:
35
+ # Model is technically the "deployment_id" in Azure URL,
36
+ # but often passed in body as well for validation.
37
+ model: model
38
+ messages: messages
39
+ max_tokens: max_tokens
40
+ temperature: temperature
41
+ stream: stream
42
+ tools: tools
43
+ tool_choice: tool_choice
44
+
45
+ streaming:
46
+ event_format: "data_lines"
47
+ decoder:
48
+ format: "sse"
49
+ delimiter: "\n\n"
50
+ prefix: "data: "
51
+ done_signal: "[DONE]"
52
+ frame_selector: "exists($.choices) || exists($.error)"
53
+ candidate:
54
+ candidate_id_path: "$.choices[*].index"
55
+ fan_out: true
56
+ event_map:
57
+ - match: "exists($.error)"
58
+ emit: "StreamError"
59
+ fields:
60
+ error: "$.error"
61
+ - match: "exists($.choices[*].delta.content)"
62
+ emit: "PartialContentDelta"
63
+ fields:
64
+ content: "$.choices[*].delta.content"
65
+ - match: "exists($.choices[*].delta.tool_calls[*].function.name)"
66
+ emit: "ToolCallStarted"
67
+ fields:
68
+ tool_call_id: "$.choices[*].delta.tool_calls[*].id"
69
+ tool_name: "$.choices[*].delta.tool_calls[*].function.name"
70
+ index: "$.choices[*].delta.tool_calls[*].index"
71
+ - match: "exists($.choices[*].delta.tool_calls[*].function.arguments)"
72
+ emit: "PartialToolCall"
73
+ fields:
74
+ arguments: "$.choices[*].delta.tool_calls[*].function.arguments"
75
+ index: "$.choices[*].delta.tool_calls[*].index"
76
+ - match: "exists($.usage)"
77
+ emit: "Metadata"
78
+ fields:
79
+ usage: "$.usage"
80
+ - match: "exists($.choices[*].finish_reason)"
81
+ emit: "FinalCandidate"
82
+ fields:
83
+ finish_reason: "$.choices[*].finish_reason"
84
+ candidate_index: "$.choices[*].index"
85
+ stop_condition: "$.choices[0].finish_reason != null"
86
+ extra_metadata_path: "$.usage"
87
+ content_path: "$.choices[0].delta.content"
88
+ tool_call_path: "$.choices[0].delta.tool_calls"
89
+
90
+ # Termination reason normalization (Azure OpenAI uses OpenAI-compatible finish_reason)
91
+ termination:
92
+ source_field: "finish_reason"
93
+ mapping:
94
+ stop: "end_turn"
95
+ length: "max_tokens"
96
+ tool_calls: "tool_use"
97
+ content_filter: "refusal"
98
+ notes:
99
+ - "finish_reason is reported per candidate."
100
+
101
+ # Tool invocation normalization (Azure OpenAI is OpenAI-compatible)
102
+ tooling:
103
+ source_model: "openai_tool_calls"
104
+ tool_use:
105
+ id_path: "id"
106
+ name_path: "function.name"
107
+ input_path: "function.arguments"
108
+ input_format: "json_string"
109
+ notes:
110
+ - "Azure OpenAI tool_calls.function.arguments is typically a JSON string."
111
+
112
+ features:
113
+ multi_candidate:
114
+ support_type: "native"
115
+ param_name: "n"
116
+ response_mapping:
117
+ tool_calls:
118
+ path: "choices[0].message.tool_calls"
119
+ fields:
120
+ id: "id"
121
+ name: "function.name"
122
+ args: "function.arguments"
123
+ error:
124
+ message_path: "error.message"
125
+ code_path: "error.code"
126
+ type_path: "error.type"
127
+ param_path: "error.param"
128
+
129
+ response_paths:
130
+ content: "choices[0].message.content"
131
+ tool_calls: "choices[0].message.tool_calls"
132
+ usage: "usage"
133
+ finish_reason: "choices[0].finish_reason"
134
+
135
+ retry_policy:
136
+ max_retries: 3
137
+ max_delay_ms: 30000
138
+ strategy: "exponential_backoff"
139
+ min_delay_ms: 1000
140
+ jitter: "full"
141
+ retry_on_http_status: [429, 500, 502, 503]
142
+
143
+ error_classification:
144
+ by_http_status:
145
+ "400": "invalid_request"
146
+ "401": "authentication"
147
+ "403": "permission_denied"
148
+ "404": "not_found"
149
+ "429": "rate_limited"
150
+ "500": "server_error"
151
+
152
+ rate_limit_headers:
153
+ requests_limit: "x-ratelimit-limit-requests"
154
+ requests_remaining: "x-ratelimit-remaining-requests"
155
+ requests_reset: "x-ratelimit-reset-requests"
@@ -0,0 +1,168 @@
1
+ $schema: "https://raw.githubusercontent.com/ailib-official/ai-protocol/main/schemas/v1.json"
2
+
3
+ id: baichuan
4
+ protocol_version: "1.5"
5
+
6
+ name: 百川智能 (Baichuan)
7
+ version: "v1"
8
+ status: stable
9
+ category: ai_provider
10
+ official_url: "https://platform.baichuan-ai.com/docs/api"
11
+ support_contact: "https://www.baichuan-ai.com/contact"
12
+
13
+ endpoint:
14
+ base_url: "https://api.baichuan-ai.com/v1"
15
+ protocol: https
16
+ timeout_ms: 60000
17
+
18
+ auth:
19
+ type: bearer
20
+ token_env: "BAICHUAN_API_KEY"
21
+
22
+ payload_format: "openai_style"
23
+
24
+ # OpenAI-compatible API
25
+ api_families: ["chat_completions"]
26
+ default_api_family: "chat_completions"
27
+
28
+ endpoints:
29
+ chat:
30
+ path: "/chat/completions"
31
+ method: "POST"
32
+ adapter: "openai"
33
+
34
+ services:
35
+ list_models:
36
+ path: "/models"
37
+ method: "GET"
38
+ response_binding: "data"
39
+
40
+ termination:
41
+ source_field: "finish_reason"
42
+ mapping:
43
+ stop: "end_turn"
44
+ length: "max_tokens"
45
+ tool_calls: "tool_use"
46
+ notes:
47
+ - "OpenAI-compatible finish_reason."
48
+ - "Baichuan is a leading Chinese AI company founded by former Sogou CEO."
49
+
50
+ tooling:
51
+ source_model: "openai_tool_calls"
52
+ tool_use:
53
+ id_path: "id"
54
+ name_path: "function.name"
55
+ input_path: "function.arguments"
56
+ input_format: "json_string"
57
+ notes:
58
+ - "Supports OpenAI-compatible function calling."
59
+
60
+ retry_policy:
61
+ strategy: "exponential_backoff"
62
+ max_retries: 3
63
+ min_delay_ms: 1000
64
+ max_delay_ms: 30000
65
+ jitter: "full"
66
+ retry_on_http_status: [429, 500, 502, 503]
67
+
68
+ error_classification:
69
+ by_http_status:
70
+ "400": "invalid_request"
71
+ "401": "authentication"
72
+ "403": "permission_denied"
73
+ "404": "not_found"
74
+ "429": "rate_limited"
75
+ "500": "server_error"
76
+ "503": "overloaded"
77
+
78
+ parameter_mappings:
79
+ temperature: "temperature"
80
+ max_tokens: "max_tokens"
81
+ stream: "stream"
82
+ top_p: "top_p"
83
+ top_k: "top_k"
84
+ stop_sequences: "stop"
85
+ tools: "tools"
86
+ tool_choice: "tool_choice"
87
+
88
+ response_format: "openai_style"
89
+
90
+ response_paths:
91
+ content: "choices[0].message.content"
92
+ tool_calls: "choices[0].message.tool_calls"
93
+ usage: "usage"
94
+ finish_reason: "choices[0].finish_reason"
95
+
96
+ streaming:
97
+ event_format: "data_lines"
98
+ decoder:
99
+ format: "sse"
100
+ delimiter: "\n\n"
101
+ prefix: "data: "
102
+ done_signal: "[DONE]"
103
+ content_path: "choices[0].delta.content"
104
+ tool_call_path: "choices[0].delta.tool_calls"
105
+ usage_path: "usage"
106
+ frame_selector: "exists($.choices) || exists($.error)"
107
+ event_map:
108
+ - match: "exists($.choices[*].delta.content)"
109
+ emit: "PartialContentDelta"
110
+ fields:
111
+ content: "$.choices[*].delta.content"
112
+ - match: "exists($.choices[*].delta.tool_calls[*].function.name)"
113
+ emit: "ToolCallStarted"
114
+ fields:
115
+ tool_call_id: "$.choices[*].delta.tool_calls[*].id"
116
+ tool_name: "$.choices[*].delta.tool_calls[*].function.name"
117
+ index: "$.choices[*].delta.tool_calls[*].index"
118
+ - match: "exists($.choices[*].delta.tool_calls[*].function.arguments)"
119
+ emit: "PartialToolCall"
120
+ fields:
121
+ arguments: "$.choices[*].delta.tool_calls[*].function.arguments"
122
+ index: "$.choices[*].delta.tool_calls[*].index"
123
+ - match: "exists($.usage)"
124
+ emit: "Metadata"
125
+ fields:
126
+ usage: "$.usage"
127
+ - match: "exists($.choices[*].finish_reason)"
128
+ emit: "FinalCandidate"
129
+ fields:
130
+ finish_reason: "$.choices[*].finish_reason"
131
+ stop_condition: "$.choices[0].finish_reason != null"
132
+
133
+ features:
134
+ multi_candidate:
135
+ support_type: "native"
136
+ param_name: "n"
137
+ response_mapping:
138
+ tool_calls:
139
+ path: "choices[0].message.tool_calls"
140
+ fields:
141
+ id: "id"
142
+ name: "function.name"
143
+ args: "function.arguments"
144
+ error:
145
+ message_path: "error.message"
146
+ code_path: "error.code"
147
+
148
+ capabilities:
149
+ streaming: true
150
+ tools: true
151
+ vision: false
152
+ agentic: true
153
+ parallel_tools: false
154
+ reasoning: false
155
+
156
+ availability:
157
+ required: false
158
+ regions:
159
+ - cn
160
+ check:
161
+ method: GET
162
+ path: "/models"
163
+ expected_status: [200, 401]
164
+ timeout_ms: 5000
165
+
166
+ experimental_features:
167
+ - "knowledge_base"
168
+ - "web_search"
@@ -0,0 +1,173 @@
1
+ $schema: "https://raw.githubusercontent.com/ailib-official/ai-protocol/main/schemas/v1.json"
2
+
3
+ id: baidu
4
+ protocol_version: "1.5"
5
+
6
+ name: 百度文心 (Baidu ERNIE)
7
+ version: "v1"
8
+ status: stable
9
+ category: ai_provider
10
+ official_url: "https://cloud.baidu.com/doc/WENXINWORKSHOP/index.html"
11
+ support_contact: "https://cloud.baidu.com/support"
12
+
13
+ endpoint:
14
+ base_url: "https://aip.baidubce.com/rpc/2.0/ai_custom/v1/wenxinworkshop"
15
+ protocol: https
16
+ timeout_ms: 60000
17
+
18
+ # Baidu uses access_token obtained via API Key + Secret Key
19
+ auth:
20
+ type: bearer
21
+ token_env: "BAIDU_ACCESS_TOKEN"
22
+
23
+ payload_format: "baidu_style"
24
+
25
+ # Baidu ERNIE API families
26
+ api_families: ["chat"]
27
+ default_api_family: "chat"
28
+
29
+ endpoints:
30
+ # ERNIE 4.0
31
+ chat_ernie4:
32
+ path: "/chat/completions_pro"
33
+ method: "POST"
34
+ adapter: "baidu"
35
+ # ERNIE 3.5
36
+ chat_ernie35:
37
+ path: "/chat/completions"
38
+ method: "POST"
39
+ adapter: "baidu"
40
+ # ERNIE Speed
41
+ chat_ernie_speed:
42
+ path: "/chat/ernie_speed"
43
+ method: "POST"
44
+ adapter: "baidu"
45
+ # ERNIE Lite
46
+ chat_ernie_lite:
47
+ path: "/chat/ernie-lite-8k"
48
+ method: "POST"
49
+ adapter: "baidu"
50
+
51
+ termination:
52
+ source_field: "finish_reason"
53
+ mapping:
54
+ normal: "end_turn"
55
+ stop: "end_turn"
56
+ length: "max_tokens"
57
+ content_filter: "refusal"
58
+ function_call: "tool_use"
59
+ notes:
60
+ - "Baidu ERNIE uses finish_reason in response."
61
+ - "文心一言 (ERNIE Bot) is Baidu's flagship conversational AI."
62
+
63
+ tooling:
64
+ source_model: "openai_tool_calls"
65
+ tool_use:
66
+ id_path: "id"
67
+ name_path: "name"
68
+ input_path: "arguments"
69
+ input_format: "json_string"
70
+ notes:
71
+ - "ERNIE supports function calling with similar semantics to OpenAI."
72
+
73
+ retry_policy:
74
+ strategy: "exponential_backoff"
75
+ max_retries: 3
76
+ min_delay_ms: 1000
77
+ max_delay_ms: 30000
78
+ jitter: "full"
79
+ retry_on_http_status: [429, 500, 502, 503]
80
+
81
+ error_classification:
82
+ by_http_status:
83
+ "400": "invalid_request"
84
+ "401": "authentication"
85
+ "403": "permission_denied"
86
+ "404": "not_found"
87
+ "429": "rate_limited"
88
+ "500": "server_error"
89
+ "503": "overloaded"
90
+
91
+ parameter_mappings:
92
+ temperature: "temperature"
93
+ max_tokens: "max_output_tokens"
94
+ stream: "stream"
95
+ top_p: "top_p"
96
+ stop_sequences: "stop"
97
+ tools: "functions"
98
+ system_message: "system"
99
+
100
+ response_format: "baidu_style"
101
+
102
+ response_paths:
103
+ content: "result"
104
+ function_call: "function_call"
105
+ usage: "usage"
106
+ finish_reason: "finish_reason"
107
+
108
+ streaming:
109
+ event_format: "data_lines"
110
+ decoder:
111
+ format: "sse"
112
+ delimiter: "\n\n"
113
+ prefix: "data: "
114
+ done_signal: ""
115
+ content_path: "result"
116
+ usage_path: "usage"
117
+ frame_selector: "exists($.result) || exists($.error_code)"
118
+ event_map:
119
+ - match: "exists($.result)"
120
+ emit: "PartialContentDelta"
121
+ fields:
122
+ content: "$.result"
123
+ - match: "exists($.function_call)"
124
+ emit: "ToolCallStarted"
125
+ fields:
126
+ tool_name: "$.function_call.name"
127
+ arguments: "$.function_call.arguments"
128
+ - match: "exists($.usage)"
129
+ emit: "Metadata"
130
+ fields:
131
+ usage: "$.usage"
132
+ - match: "$.is_end == true"
133
+ emit: "FinalCandidate"
134
+ fields:
135
+ finish_reason: "$.finish_reason"
136
+ stop_condition: "$.is_end == true"
137
+
138
+ features:
139
+ multi_candidate:
140
+ support_type: "simulated"
141
+ max_concurrent: 1
142
+ response_mapping:
143
+ function_call:
144
+ path: "function_call"
145
+ fields:
146
+ name: "name"
147
+ args: "arguments"
148
+ error:
149
+ message_path: "error_msg"
150
+ code_path: "error_code"
151
+
152
+ capabilities:
153
+ streaming: true
154
+ tools: true
155
+ vision: true
156
+ agentic: true
157
+ parallel_tools: false
158
+ reasoning: false
159
+
160
+ availability:
161
+ required: false
162
+ regions:
163
+ - cn
164
+ check:
165
+ method: GET
166
+ path: "/chat/completions"
167
+ expected_status: [200, 401, 403]
168
+ timeout_ms: 5000
169
+
170
+ experimental_features:
171
+ - "knowledge_base"
172
+ - "plugins"
173
+ - "image_understanding"
@@ -0,0 +1,178 @@
1
+ $schema: "https://raw.githubusercontent.com/ailib-official/ai-protocol/main/schemas/v1.json"
2
+
3
+ id: cerebras
4
+ protocol_version: "1.5"
5
+
6
+ name: Cerebras
7
+ version: "v1"
8
+ status: stable
9
+ category: ai_provider
10
+ official_url: "https://inference-docs.cerebras.ai"
11
+ support_contact: "https://cerebras.ai/contact"
12
+
13
+ endpoint:
14
+ base_url: "https://api.cerebras.ai/v1"
15
+ protocol: https
16
+ timeout_ms: 10000
17
+
18
+ auth:
19
+ type: bearer
20
+ token_env: "CEREBRAS_API_KEY"
21
+
22
+ payload_format: "openai_style"
23
+
24
+ # OpenAI-compatible API
25
+ api_families: ["chat_completions"]
26
+ default_api_family: "chat_completions"
27
+
28
+ endpoints:
29
+ chat:
30
+ path: "/chat/completions"
31
+ method: "POST"
32
+ adapter: "openai"
33
+
34
+ services:
35
+ list_models:
36
+ path: "/models"
37
+ method: "GET"
38
+ response_binding: "data"
39
+
40
+ termination:
41
+ source_field: "finish_reason"
42
+ mapping:
43
+ stop: "end_turn"
44
+ length: "max_tokens"
45
+ tool_calls: "tool_use"
46
+ notes:
47
+ - "OpenAI-compatible finish_reason."
48
+ - "Cerebras is known for extremely fast inference (thousands of tokens/second)."
49
+
50
+ tooling:
51
+ source_model: "openai_tool_calls"
52
+ tool_use:
53
+ id_path: "id"
54
+ name_path: "function.name"
55
+ input_path: "function.arguments"
56
+ input_format: "json_string"
57
+ notes:
58
+ - "Standard OpenAI-compatible tool calling."
59
+
60
+ rate_limit_headers:
61
+ requests_limit: "x-ratelimit-limit-requests"
62
+ requests_remaining: "x-ratelimit-remaining-requests"
63
+ tokens_limit: "x-ratelimit-limit-tokens"
64
+ tokens_remaining: "x-ratelimit-remaining-tokens"
65
+
66
+ retry_policy:
67
+ strategy: "exponential_backoff"
68
+ max_retries: 3
69
+ min_delay_ms: 500
70
+ max_delay_ms: 10000
71
+ jitter: "full"
72
+ retry_on_http_status: [429, 500, 502, 503]
73
+ notes:
74
+ - "Cerebras inference is extremely fast; shorter retry delays are appropriate."
75
+
76
+ error_classification:
77
+ by_http_status:
78
+ "400": "invalid_request"
79
+ "401": "authentication"
80
+ "403": "permission_denied"
81
+ "404": "not_found"
82
+ "429": "rate_limited"
83
+ "500": "server_error"
84
+ "503": "overloaded"
85
+
86
+ parameter_mappings:
87
+ temperature: "temperature"
88
+ max_tokens: "max_tokens"
89
+ stream: "stream"
90
+ top_p: "top_p"
91
+ stop_sequences: "stop"
92
+ tools: "tools"
93
+ tool_choice: "tool_choice"
94
+ seed: "seed"
95
+
96
+ response_format: "openai_style"
97
+
98
+ response_paths:
99
+ content: "choices[0].message.content"
100
+ tool_calls: "choices[0].message.tool_calls"
101
+ usage: "usage"
102
+ finish_reason: "choices[0].finish_reason"
103
+
104
+ streaming:
105
+ event_format: "data_lines"
106
+ decoder:
107
+ format: "sse"
108
+ delimiter: "\n\n"
109
+ prefix: "data: "
110
+ done_signal: "[DONE]"
111
+ content_path: "choices[0].delta.content"
112
+ tool_call_path: "choices[0].delta.tool_calls"
113
+ usage_path: "usage"
114
+ frame_selector: "exists($.choices) || exists($.error)"
115
+ event_map:
116
+ - match: "exists($.choices[*].delta.content)"
117
+ emit: "PartialContentDelta"
118
+ fields:
119
+ content: "$.choices[*].delta.content"
120
+ - match: "exists($.choices[*].delta.tool_calls[*].function.name)"
121
+ emit: "ToolCallStarted"
122
+ fields:
123
+ tool_call_id: "$.choices[*].delta.tool_calls[*].id"
124
+ tool_name: "$.choices[*].delta.tool_calls[*].function.name"
125
+ index: "$.choices[*].delta.tool_calls[*].index"
126
+ - match: "exists($.choices[*].delta.tool_calls[*].function.arguments)"
127
+ emit: "PartialToolCall"
128
+ fields:
129
+ arguments: "$.choices[*].delta.tool_calls[*].function.arguments"
130
+ index: "$.choices[*].delta.tool_calls[*].index"
131
+ - match: "exists($.usage)"
132
+ emit: "Metadata"
133
+ fields:
134
+ usage: "$.usage"
135
+ - match: "exists($.choices[*].finish_reason)"
136
+ emit: "FinalCandidate"
137
+ fields:
138
+ finish_reason: "$.choices[*].finish_reason"
139
+ candidate_index: "$.choices[*].index"
140
+ stop_condition: "$.choices[0].finish_reason != null"
141
+
142
+ features:
143
+ multi_candidate:
144
+ support_type: "native"
145
+ param_name: "n"
146
+ response_mapping:
147
+ tool_calls:
148
+ path: "choices[0].message.tool_calls"
149
+ fields:
150
+ id: "id"
151
+ name: "function.name"
152
+ args: "function.arguments"
153
+ error:
154
+ message_path: "error.message"
155
+ code_path: "error.code"
156
+ type_path: "error.type"
157
+
158
+ capabilities:
159
+ streaming: true
160
+ tools: true
161
+ vision: false
162
+ agentic: true
163
+ parallel_tools: true
164
+ reasoning: false
165
+
166
+ availability:
167
+ required: false
168
+ regions:
169
+ - global
170
+ check:
171
+ method: GET
172
+ path: "/models"
173
+ expected_status: [200, 401]
174
+ timeout_ms: 3000
175
+
176
+ experimental_features:
177
+ - "ultra_fast_inference"
178
+ - "wafer_scale_engine"