@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,224 @@
|
|
|
1
|
+
$schema: "https://raw.githubusercontent.com/ailib-official/ai-protocol/main/schemas/v1.json"
|
|
2
|
+
|
|
3
|
+
id: openai
|
|
4
|
+
protocol_version: "1.5"
|
|
5
|
+
|
|
6
|
+
name: OpenAI
|
|
7
|
+
version: "v1"
|
|
8
|
+
status: stable
|
|
9
|
+
category: ai_provider
|
|
10
|
+
official_url: "https://platform.openai.com/docs"
|
|
11
|
+
support_contact: "https://help.openai.com"
|
|
12
|
+
|
|
13
|
+
# Structured endpoint definition (v1.1+ extension)
|
|
14
|
+
endpoint:
|
|
15
|
+
base_url: "https://api.openai.com/v1"
|
|
16
|
+
protocol: https
|
|
17
|
+
timeout_ms: 10000
|
|
18
|
+
|
|
19
|
+
auth:
|
|
20
|
+
type: bearer
|
|
21
|
+
token_env: "OPENAI_API_KEY"
|
|
22
|
+
payload_format: "openai_style"
|
|
23
|
+
|
|
24
|
+
# Explicit API families to avoid mixing incompatible request/response models.
|
|
25
|
+
api_families: ["chat_completions", "completions", "assistants", "realtime"]
|
|
26
|
+
default_api_family: "chat_completions"
|
|
27
|
+
endpoints:
|
|
28
|
+
chat:
|
|
29
|
+
path: "/chat/completions"
|
|
30
|
+
method: "POST"
|
|
31
|
+
adapter: "openai"
|
|
32
|
+
completions:
|
|
33
|
+
path: "/completions"
|
|
34
|
+
method: "POST"
|
|
35
|
+
adapter: "openai"
|
|
36
|
+
embeddings:
|
|
37
|
+
path: "/embeddings"
|
|
38
|
+
method: "POST"
|
|
39
|
+
adapter: "openai"
|
|
40
|
+
# Realtime (non-HTTP transport; provided as absolute URL for WS clients)
|
|
41
|
+
realtime_ws: "wss://api.openai.com/v1/realtime"
|
|
42
|
+
|
|
43
|
+
# V1.5 Service Endpoints
|
|
44
|
+
services:
|
|
45
|
+
list_models:
|
|
46
|
+
path: "/models"
|
|
47
|
+
method: "GET"
|
|
48
|
+
response_binding: "data"
|
|
49
|
+
list_files:
|
|
50
|
+
path: "/files"
|
|
51
|
+
method: "GET"
|
|
52
|
+
response_binding: "data"
|
|
53
|
+
create_batch:
|
|
54
|
+
path: "/batches"
|
|
55
|
+
method: "POST"
|
|
56
|
+
|
|
57
|
+
# Termination reason normalization (see v1/spec.yaml: standard_schema.streaming_events.termination_reasons)
|
|
58
|
+
termination:
|
|
59
|
+
source_field: "finish_reason"
|
|
60
|
+
mapping:
|
|
61
|
+
stop: "end_turn"
|
|
62
|
+
length: "max_tokens"
|
|
63
|
+
tool_calls: "tool_use"
|
|
64
|
+
content_filter: "refusal"
|
|
65
|
+
notes:
|
|
66
|
+
- "finish_reason is reported per candidate."
|
|
67
|
+
|
|
68
|
+
# Tool invocation normalization (see v1/spec.yaml: standard_schema.content_blocks)
|
|
69
|
+
tooling:
|
|
70
|
+
source_model: "openai_tool_calls"
|
|
71
|
+
tool_use:
|
|
72
|
+
id_path: "id"
|
|
73
|
+
name_path: "function.name"
|
|
74
|
+
input_path: "function.arguments"
|
|
75
|
+
input_format: "json_string"
|
|
76
|
+
notes:
|
|
77
|
+
- "OpenAI tool_calls.function.arguments is typically a JSON string; runtimes SHOULD parse it into an object when normalizing to tool_use.input."
|
|
78
|
+
|
|
79
|
+
# Rate limits (VERIFIED evidence in research/providers/openai.md: OpenAI rate limit headers)
|
|
80
|
+
rate_limit_headers:
|
|
81
|
+
requests_limit: "x-ratelimit-limit-requests"
|
|
82
|
+
tokens_limit: "x-ratelimit-limit-tokens"
|
|
83
|
+
requests_remaining: "x-ratelimit-remaining-requests"
|
|
84
|
+
tokens_remaining: "x-ratelimit-remaining-tokens"
|
|
85
|
+
requests_reset: "x-ratelimit-reset-requests"
|
|
86
|
+
tokens_reset: "x-ratelimit-reset-tokens"
|
|
87
|
+
|
|
88
|
+
# Retry policy (VERIFIED guidance: exponential backoff for 429; 500 retry after brief wait)
|
|
89
|
+
retry_policy:
|
|
90
|
+
max_retries: 3
|
|
91
|
+
max_delay_ms: 30000
|
|
92
|
+
strategy: "exponential_backoff"
|
|
93
|
+
min_delay_ms: 1000
|
|
94
|
+
jitter: "full"
|
|
95
|
+
retry_on_http_status: [429, 500, 502, 503]
|
|
96
|
+
notes:
|
|
97
|
+
- "429 may be rate limit reached OR quota exhausted; runtimes SHOULD avoid retrying quota-exhausted cases when detectable (e.g., via error message)."
|
|
98
|
+
- "For rate limit errors, exponential backoff is recommended."
|
|
99
|
+
- "For 500 server errors, retry after a brief wait."
|
|
100
|
+
|
|
101
|
+
# Error classification hints (see v1/spec.yaml: standard_schema.error_handling.error_classes)
|
|
102
|
+
error_classification:
|
|
103
|
+
by_http_status:
|
|
104
|
+
"400": "invalid_request"
|
|
105
|
+
"401": "authentication"
|
|
106
|
+
"403": "permission_denied"
|
|
107
|
+
"404": "not_found"
|
|
108
|
+
"429": "rate_limited"
|
|
109
|
+
"500": "server_error"
|
|
110
|
+
notes:
|
|
111
|
+
- "OpenAI 429 may also indicate quota/billing exhaustion; runtimes SHOULD treat it as quota_exhausted when the message indicates plan/billing/quota."
|
|
112
|
+
parameter_mappings:
|
|
113
|
+
temperature: "temperature"
|
|
114
|
+
max_tokens: "max_tokens"
|
|
115
|
+
stream: "stream"
|
|
116
|
+
top_p: "top_p"
|
|
117
|
+
stop_sequences: "stop"
|
|
118
|
+
frequency_penalty: "frequency_penalty"
|
|
119
|
+
presence_penalty: "presence_penalty"
|
|
120
|
+
logprobs: "logprobs"
|
|
121
|
+
top_logprobs: "top_logprobs"
|
|
122
|
+
seed: "seed"
|
|
123
|
+
tools: "tools"
|
|
124
|
+
tool_choice: "tool_choice"
|
|
125
|
+
reasoning_effort: "reasoning_effort"
|
|
126
|
+
response_format: "openai_style"
|
|
127
|
+
response_paths:
|
|
128
|
+
content: "choices[0].message.content"
|
|
129
|
+
tool_calls: "choices[0].message.tool_calls"
|
|
130
|
+
usage: "usage"
|
|
131
|
+
finish_reason: "choices[0].finish_reason"
|
|
132
|
+
streaming:
|
|
133
|
+
event_format: "data_lines"
|
|
134
|
+
decoder:
|
|
135
|
+
format: "sse"
|
|
136
|
+
delimiter: "\n\n"
|
|
137
|
+
prefix: "data: "
|
|
138
|
+
done_signal: "[DONE]"
|
|
139
|
+
# Allow both normal Chat Completions frames and stream/realtime error frames.
|
|
140
|
+
frame_selector: "exists($.choices) || exists($.error) || $.type == 'error'"
|
|
141
|
+
candidate:
|
|
142
|
+
candidate_id_path: "$.choices[*].index"
|
|
143
|
+
fan_out: true
|
|
144
|
+
event_map:
|
|
145
|
+
# Stream/realtime error event (first-class event)
|
|
146
|
+
- match: "exists($.error) || $.type == 'error'"
|
|
147
|
+
emit: "StreamError"
|
|
148
|
+
fields:
|
|
149
|
+
type: "$.type"
|
|
150
|
+
event_id: "$.event_id"
|
|
151
|
+
error: "$.error"
|
|
152
|
+
# Text content delta (supports multi-candidate via choices array)
|
|
153
|
+
- match: "exists($.choices[*].delta.content)"
|
|
154
|
+
emit: "PartialContentDelta"
|
|
155
|
+
fields:
|
|
156
|
+
content: "$.choices[*].delta.content"
|
|
157
|
+
# Tool call start (first chunk with tool_calls)
|
|
158
|
+
- match: "exists($.choices[*].delta.tool_calls[*].function.name)"
|
|
159
|
+
emit: "ToolCallStarted"
|
|
160
|
+
fields:
|
|
161
|
+
tool_call_id: "$.choices[*].delta.tool_calls[*].id"
|
|
162
|
+
tool_name: "$.choices[*].delta.tool_calls[*].function.name"
|
|
163
|
+
index: "$.choices[*].delta.tool_calls[*].index"
|
|
164
|
+
# Tool call arguments streaming
|
|
165
|
+
- match: "exists($.choices[*].delta.tool_calls[*].function.arguments)"
|
|
166
|
+
emit: "PartialToolCall"
|
|
167
|
+
fields:
|
|
168
|
+
arguments: "$.choices[*].delta.tool_calls[*].function.arguments"
|
|
169
|
+
index: "$.choices[*].delta.tool_calls[*].index"
|
|
170
|
+
# Usage metadata (OpenAI returns usage in final chunk with stream_options)
|
|
171
|
+
- match: "exists($.usage)"
|
|
172
|
+
emit: "Metadata"
|
|
173
|
+
fields:
|
|
174
|
+
usage: "$.usage"
|
|
175
|
+
prompt_tokens: "$.usage.prompt_tokens"
|
|
176
|
+
completion_tokens: "$.usage.completion_tokens"
|
|
177
|
+
# Finish with reason
|
|
178
|
+
- match: "exists($.choices[*].finish_reason)"
|
|
179
|
+
emit: "FinalCandidate"
|
|
180
|
+
fields:
|
|
181
|
+
finish_reason: "$.choices[*].finish_reason"
|
|
182
|
+
candidate_index: "$.choices[*].index"
|
|
183
|
+
stop_condition: "$.choices[0].finish_reason != null"
|
|
184
|
+
extra_metadata_path: "$.usage"
|
|
185
|
+
content_path: "choices[0].delta.content"
|
|
186
|
+
tool_call_path: "choices[0].delta.tool_calls"
|
|
187
|
+
features:
|
|
188
|
+
multi_candidate:
|
|
189
|
+
support_type: "native"
|
|
190
|
+
param_name: "n"
|
|
191
|
+
response_mapping:
|
|
192
|
+
tool_calls:
|
|
193
|
+
path: "choices[0].message.tool_calls"
|
|
194
|
+
fields:
|
|
195
|
+
id: "id"
|
|
196
|
+
name: "function.name"
|
|
197
|
+
args: "function.arguments"
|
|
198
|
+
error:
|
|
199
|
+
message_path: "error.message"
|
|
200
|
+
code_path: "error.code"
|
|
201
|
+
type_path: "error.type"
|
|
202
|
+
param_path: "error.param"
|
|
203
|
+
capabilities:
|
|
204
|
+
streaming: true
|
|
205
|
+
tools: true
|
|
206
|
+
vision: true
|
|
207
|
+
agentic: true
|
|
208
|
+
parallel_tools: true
|
|
209
|
+
reasoning: true
|
|
210
|
+
experimental_features:
|
|
211
|
+
- "strict_tools"
|
|
212
|
+
- "parallel_tool_calls"
|
|
213
|
+
- "responses_api"
|
|
214
|
+
|
|
215
|
+
# Availability and health checking (v1.1+ extension)
|
|
216
|
+
availability:
|
|
217
|
+
required: false
|
|
218
|
+
regions:
|
|
219
|
+
- global
|
|
220
|
+
check:
|
|
221
|
+
method: GET
|
|
222
|
+
path: "/models"
|
|
223
|
+
expected_status: [200, 401]
|
|
224
|
+
timeout_ms: 3000
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
$schema: "https://raw.githubusercontent.com/ailib-official/ai-protocol/main/schemas/v1.json"
|
|
2
|
+
|
|
3
|
+
id: openrouter
|
|
4
|
+
protocol_version: "1.5"
|
|
5
|
+
|
|
6
|
+
name: OpenRouter
|
|
7
|
+
version: "v1"
|
|
8
|
+
status: stable
|
|
9
|
+
category: third_party_aggregator
|
|
10
|
+
official_url: "https://openrouter.ai/docs"
|
|
11
|
+
support_contact: "https://openrouter.ai/contact"
|
|
12
|
+
|
|
13
|
+
endpoint:
|
|
14
|
+
base_url: "https://openrouter.ai/api/v1"
|
|
15
|
+
protocol: https
|
|
16
|
+
timeout_ms: 120000
|
|
17
|
+
|
|
18
|
+
auth:
|
|
19
|
+
type: bearer
|
|
20
|
+
token_env: "OPENROUTER_API_KEY"
|
|
21
|
+
|
|
22
|
+
payload_format: "openai_style"
|
|
23
|
+
|
|
24
|
+
# OpenAI-compatible API (aggregates multiple providers)
|
|
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
|
+
get_generation:
|
|
40
|
+
path: "/generation"
|
|
41
|
+
method: "GET"
|
|
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
|
+
notes:
|
|
51
|
+
- "OpenRouter normalizes responses to OpenAI format."
|
|
52
|
+
- "Aggregates 100+ models from various providers."
|
|
53
|
+
|
|
54
|
+
tooling:
|
|
55
|
+
source_model: "openai_tool_calls"
|
|
56
|
+
tool_use:
|
|
57
|
+
id_path: "id"
|
|
58
|
+
name_path: "function.name"
|
|
59
|
+
input_path: "function.arguments"
|
|
60
|
+
input_format: "json_string"
|
|
61
|
+
notes:
|
|
62
|
+
- "Tool support depends on underlying model."
|
|
63
|
+
|
|
64
|
+
retry_policy:
|
|
65
|
+
strategy: "exponential_backoff"
|
|
66
|
+
max_retries: 3
|
|
67
|
+
min_delay_ms: 1000
|
|
68
|
+
max_delay_ms: 60000
|
|
69
|
+
jitter: "full"
|
|
70
|
+
retry_on_http_status: [429, 500, 502, 503]
|
|
71
|
+
notes:
|
|
72
|
+
- "OpenRouter may have longer latencies due to routing."
|
|
73
|
+
|
|
74
|
+
error_classification:
|
|
75
|
+
by_http_status:
|
|
76
|
+
"400": "invalid_request"
|
|
77
|
+
"401": "authentication"
|
|
78
|
+
"402": "quota_exhausted"
|
|
79
|
+
"403": "permission_denied"
|
|
80
|
+
"404": "not_found"
|
|
81
|
+
"429": "rate_limited"
|
|
82
|
+
"500": "server_error"
|
|
83
|
+
"502": "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
|
+
frequency_penalty: "frequency_penalty"
|
|
92
|
+
presence_penalty: "presence_penalty"
|
|
93
|
+
stop_sequences: "stop"
|
|
94
|
+
tools: "tools"
|
|
95
|
+
tool_choice: "tool_choice"
|
|
96
|
+
seed: "seed"
|
|
97
|
+
top_k: "top_k"
|
|
98
|
+
|
|
99
|
+
response_format: "openai_style"
|
|
100
|
+
|
|
101
|
+
response_paths:
|
|
102
|
+
content: "choices[0].message.content"
|
|
103
|
+
tool_calls: "choices[0].message.tool_calls"
|
|
104
|
+
usage: "usage"
|
|
105
|
+
finish_reason: "choices[0].finish_reason"
|
|
106
|
+
|
|
107
|
+
streaming:
|
|
108
|
+
event_format: "data_lines"
|
|
109
|
+
decoder:
|
|
110
|
+
format: "sse"
|
|
111
|
+
delimiter: "\n\n"
|
|
112
|
+
prefix: "data: "
|
|
113
|
+
done_signal: "[DONE]"
|
|
114
|
+
content_path: "choices[0].delta.content"
|
|
115
|
+
tool_call_path: "choices[0].delta.tool_calls"
|
|
116
|
+
usage_path: "usage"
|
|
117
|
+
frame_selector: "exists($.choices) || exists($.error)"
|
|
118
|
+
event_map:
|
|
119
|
+
- match: "exists($.choices[*].delta.content)"
|
|
120
|
+
emit: "PartialContentDelta"
|
|
121
|
+
fields:
|
|
122
|
+
content: "$.choices[*].delta.content"
|
|
123
|
+
- match: "exists($.choices[*].delta.tool_calls[*].function.name)"
|
|
124
|
+
emit: "ToolCallStarted"
|
|
125
|
+
fields:
|
|
126
|
+
tool_call_id: "$.choices[*].delta.tool_calls[*].id"
|
|
127
|
+
tool_name: "$.choices[*].delta.tool_calls[*].function.name"
|
|
128
|
+
index: "$.choices[*].delta.tool_calls[*].index"
|
|
129
|
+
- match: "exists($.choices[*].delta.tool_calls[*].function.arguments)"
|
|
130
|
+
emit: "PartialToolCall"
|
|
131
|
+
fields:
|
|
132
|
+
arguments: "$.choices[*].delta.tool_calls[*].function.arguments"
|
|
133
|
+
index: "$.choices[*].delta.tool_calls[*].index"
|
|
134
|
+
- match: "exists($.usage)"
|
|
135
|
+
emit: "Metadata"
|
|
136
|
+
fields:
|
|
137
|
+
usage: "$.usage"
|
|
138
|
+
- match: "exists($.choices[*].finish_reason)"
|
|
139
|
+
emit: "FinalCandidate"
|
|
140
|
+
fields:
|
|
141
|
+
finish_reason: "$.choices[*].finish_reason"
|
|
142
|
+
stop_condition: "$.choices[0].finish_reason != null"
|
|
143
|
+
|
|
144
|
+
features:
|
|
145
|
+
multi_candidate:
|
|
146
|
+
support_type: "native"
|
|
147
|
+
param_name: "n"
|
|
148
|
+
response_mapping:
|
|
149
|
+
tool_calls:
|
|
150
|
+
path: "choices[0].message.tool_calls"
|
|
151
|
+
fields:
|
|
152
|
+
id: "id"
|
|
153
|
+
name: "function.name"
|
|
154
|
+
args: "function.arguments"
|
|
155
|
+
error:
|
|
156
|
+
message_path: "error.message"
|
|
157
|
+
code_path: "error.code"
|
|
158
|
+
type_path: "error.type"
|
|
159
|
+
|
|
160
|
+
capabilities:
|
|
161
|
+
streaming: true
|
|
162
|
+
tools: true
|
|
163
|
+
vision: true
|
|
164
|
+
agentic: true
|
|
165
|
+
parallel_tools: true
|
|
166
|
+
reasoning: true
|
|
167
|
+
|
|
168
|
+
availability:
|
|
169
|
+
required: false
|
|
170
|
+
regions:
|
|
171
|
+
- global
|
|
172
|
+
check:
|
|
173
|
+
method: GET
|
|
174
|
+
path: "/models"
|
|
175
|
+
expected_status: [200, 401]
|
|
176
|
+
timeout_ms: 5000
|
|
177
|
+
|
|
178
|
+
experimental_features:
|
|
179
|
+
- "model_routing"
|
|
180
|
+
- "fallback_models"
|
|
181
|
+
- "cost_tracking"
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
$schema: "https://raw.githubusercontent.com/ailib-official/ai-protocol/main/schemas/v1.json"
|
|
2
|
+
|
|
3
|
+
id: perplexity
|
|
4
|
+
protocol_version: "1.5"
|
|
5
|
+
|
|
6
|
+
name: Perplexity
|
|
7
|
+
version: "v1"
|
|
8
|
+
status: stable
|
|
9
|
+
category: ai_provider
|
|
10
|
+
official_url: "https://docs.perplexity.ai"
|
|
11
|
+
support_contact: "https://www.perplexity.ai/contact"
|
|
12
|
+
|
|
13
|
+
endpoint:
|
|
14
|
+
base_url: "https://api.perplexity.ai"
|
|
15
|
+
protocol: https
|
|
16
|
+
timeout_ms: 60000
|
|
17
|
+
|
|
18
|
+
auth:
|
|
19
|
+
type: bearer
|
|
20
|
+
token_env: "PPLX_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
|
+
notes:
|
|
46
|
+
- "Perplexity is known for search-augmented AI responses."
|
|
47
|
+
- "Returns citations in responses when using online models."
|
|
48
|
+
|
|
49
|
+
tooling:
|
|
50
|
+
source_model: "unknown"
|
|
51
|
+
notes:
|
|
52
|
+
- "Perplexity focuses on search/RAG, limited tool support."
|
|
53
|
+
|
|
54
|
+
retry_policy:
|
|
55
|
+
strategy: "exponential_backoff"
|
|
56
|
+
max_retries: 3
|
|
57
|
+
min_delay_ms: 1000
|
|
58
|
+
max_delay_ms: 30000
|
|
59
|
+
jitter: "full"
|
|
60
|
+
retry_on_http_status: [429, 500, 502, 503]
|
|
61
|
+
|
|
62
|
+
error_classification:
|
|
63
|
+
by_http_status:
|
|
64
|
+
"400": "invalid_request"
|
|
65
|
+
"401": "authentication"
|
|
66
|
+
"403": "permission_denied"
|
|
67
|
+
"404": "not_found"
|
|
68
|
+
"429": "rate_limited"
|
|
69
|
+
"500": "server_error"
|
|
70
|
+
"503": "overloaded"
|
|
71
|
+
|
|
72
|
+
parameter_mappings:
|
|
73
|
+
temperature: "temperature"
|
|
74
|
+
max_tokens: "max_tokens"
|
|
75
|
+
stream: "stream"
|
|
76
|
+
top_p: "top_p"
|
|
77
|
+
frequency_penalty: "frequency_penalty"
|
|
78
|
+
presence_penalty: "presence_penalty"
|
|
79
|
+
|
|
80
|
+
response_format: "openai_style"
|
|
81
|
+
|
|
82
|
+
response_paths:
|
|
83
|
+
content: "choices[0].message.content"
|
|
84
|
+
usage: "usage"
|
|
85
|
+
finish_reason: "choices[0].finish_reason"
|
|
86
|
+
citations: "citations"
|
|
87
|
+
|
|
88
|
+
streaming:
|
|
89
|
+
event_format: "data_lines"
|
|
90
|
+
decoder:
|
|
91
|
+
format: "sse"
|
|
92
|
+
delimiter: "\n\n"
|
|
93
|
+
prefix: "data: "
|
|
94
|
+
done_signal: "[DONE]"
|
|
95
|
+
content_path: "choices[0].delta.content"
|
|
96
|
+
usage_path: "usage"
|
|
97
|
+
frame_selector: "exists($.choices) || exists($.error)"
|
|
98
|
+
event_map:
|
|
99
|
+
- match: "exists($.choices[*].delta.content)"
|
|
100
|
+
emit: "PartialContentDelta"
|
|
101
|
+
fields:
|
|
102
|
+
content: "$.choices[*].delta.content"
|
|
103
|
+
- match: "exists($.usage)"
|
|
104
|
+
emit: "Metadata"
|
|
105
|
+
fields:
|
|
106
|
+
usage: "$.usage"
|
|
107
|
+
- match: "exists($.choices[*].finish_reason)"
|
|
108
|
+
emit: "FinalCandidate"
|
|
109
|
+
fields:
|
|
110
|
+
finish_reason: "$.choices[*].finish_reason"
|
|
111
|
+
stop_condition: "$.choices[0].finish_reason != null"
|
|
112
|
+
|
|
113
|
+
features:
|
|
114
|
+
multi_candidate:
|
|
115
|
+
support_type: "simulated"
|
|
116
|
+
max_concurrent: 1
|
|
117
|
+
response_mapping:
|
|
118
|
+
error:
|
|
119
|
+
message_path: "error.message"
|
|
120
|
+
code_path: "error.code"
|
|
121
|
+
type_path: "error.type"
|
|
122
|
+
|
|
123
|
+
capabilities:
|
|
124
|
+
streaming: true
|
|
125
|
+
tools: false
|
|
126
|
+
vision: false
|
|
127
|
+
agentic: false
|
|
128
|
+
parallel_tools: false
|
|
129
|
+
reasoning: false
|
|
130
|
+
|
|
131
|
+
availability:
|
|
132
|
+
required: false
|
|
133
|
+
regions:
|
|
134
|
+
- global
|
|
135
|
+
check:
|
|
136
|
+
method: GET
|
|
137
|
+
path: "/models"
|
|
138
|
+
expected_status: [200, 401]
|
|
139
|
+
timeout_ms: 5000
|
|
140
|
+
|
|
141
|
+
experimental_features:
|
|
142
|
+
- "online_search"
|
|
143
|
+
- "citations"
|
|
144
|
+
- "related_questions"
|