Repository navigation
Expand file tree
/
Copy pathopenapi.yaml
More file actions
493 lines (467 loc) · 14.6 KB
/
Copy pathopenapi.yaml
File metadata and controls
493 lines (467 loc) · 14.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
openapi: "3.1.0"
info:
title: AI Security Gateway API
version: "1.0.0"
description: |
OpenAI-compatible AI Gateway with built-in PII redaction, DLP enforcement,
budget caps, and smart cost routing across 60+ models and 8+ providers.
## Servers
- **Self-hosted (OSS):** `http://localhost:8000` — run via Docker Compose
- **Managed Cloud:** `https://api.aisecuritygateway.ai` — hosted, 1M free credits
## Authentication
All endpoints require a Bearer token via the `Authorization` header.
- Self-hosted: use the key defined in your `.env` file
- Cloud: Hub key (`os_hub_*`) or Project key (`oah_*`)
## Rate Limiting
10 requests/second per API key (token-bucket).
## OpenAI SDK Compatibility
Point the official OpenAI SDK at the base URL and use your API key —
all standard parameters work unchanged.
contact:
name: AI Security Gateway
url: https://aisecuritygateway.ai
license:
name: Apache-2.0
url: https://github.com/aisecuritygateway/aisecuritygateway/blob/main/LICENSE
servers:
- url: http://localhost:8000
description: Self-hosted (Docker Compose)
- url: https://api.aisecuritygateway.ai
description: Managed Cloud
security:
- BearerAuth: []
tags:
- name: Models
description: Discover available models, capabilities, and pricing.
- name: Chat
description: Generate chat completions with PII redaction and smart routing.
- name: Health
description: Service health and readiness probes.
paths:
/v1/models:
get:
operationId: listModels
summary: List available models
description: |
Returns all active models from non-disabled providers. Includes
pricing, capabilities, and provider information. Data is always
fresh — disabled providers and retired models are excluded in
real-time.
Compatible with `openai.models.list()` in the OpenAI SDK.
tags: [Models]
parameters:
- name: family
in: query
required: false
description: Filter by model family (e.g. llama, gpt, claude, gemini, deepseek, mistral, grok, qwen)
schema:
type: string
example: llama
- name: capability
in: query
required: false
description: "Filter by capability: vision, tools, json_mode, reasoning"
schema:
type: string
enum: [vision, tools, json_mode, reasoning]
- name: provider
in: query
required: false
description: Filter by provider (e.g. together, deepinfra, openai, anthropic, gemini, mistral, xai, bedrock)
schema:
type: string
example: together
responses:
"200":
description: List of available models
content:
application/json:
schema:
$ref: "#/components/schemas/ModelList"
example:
object: list
data:
- id: "oah/llama-4-maverick"
object: model
owned_by: ai-security-gateway
family: llama
supports_vision: false
supports_tools: true
supports_json_mode: true
supports_reasoning: false
context_window: 131072
max_output_tokens: 32768
providers: ["together", "deepinfra"]
pricing:
input_per_1m_tokens: 0.59
output_per_1m_tokens: 0.79
"401":
$ref: "#/components/responses/Unauthorized"
"403":
$ref: "#/components/responses/Forbidden"
"429":
$ref: "#/components/responses/RateLimited"
/v1/chat/completions:
post:
operationId: createChatCompletion
summary: Create a chat completion
description: |
Generates a model response for the given chat messages. Fully
compatible with the OpenAI Chat Completions API.
The request passes through the AI Firewall which:
1. Scans for PII (28 entity types) and applies DLP policy (block/redact)
2. Enforces budget caps and token limits (Managed Cloud only)
3. Routes to the optimal provider via Smart Router (for `oah/*` models, Cloud only)
Supports streaming via `stream: true` (Server-Sent Events).
tags: [Chat]
requestBody:
required: true
content:
application/json:
schema:
$ref: "#/components/schemas/ChatCompletionRequest"
example:
model: "oah/llama-4-maverick"
messages:
- role: user
content: "Explain the CAP theorem in distributed systems."
max_tokens: 512
responses:
"200":
description: Chat completion response
content:
application/json:
schema:
$ref: "#/components/schemas/ChatCompletionResponse"
text/event-stream:
schema:
type: string
description: SSE stream of chat completion chunks (when stream=true)
"400":
description: Bad request (unknown model, PII policy violation, vision not supported, etc.)
content:
application/json:
schema:
$ref: "#/components/schemas/ErrorResponse"
"401":
$ref: "#/components/responses/Unauthorized"
"402":
description: Insufficient wallet balance or no credentials (Managed Cloud only)
content:
application/json:
schema:
$ref: "#/components/schemas/ErrorResponse"
"403":
$ref: "#/components/responses/Forbidden"
"429":
$ref: "#/components/responses/RateLimited"
"502":
description: Provider unreachable or authentication failure
content:
application/json:
schema:
$ref: "#/components/schemas/ErrorResponse"
"504":
description: Provider timeout
content:
application/json:
schema:
$ref: "#/components/schemas/ErrorResponse"
/health:
get:
operationId: healthCheck
summary: Health check
description: |
Liveness/readiness probe. No authentication required.
Returns 200 if healthy, 207 if degraded.
tags: [Health]
security: []
responses:
"200":
description: Service is healthy
content:
application/json:
schema:
type: object
properties:
status:
type: string
example: healthy
components:
securitySchemes:
BearerAuth:
type: http
scheme: bearer
description: |
API key as Bearer token.
- Self-hosted: key from your .env file
- Cloud: Hub key (`os_hub_*`) or Project key (`oah_*`)
schemas:
ModelList:
type: object
properties:
object:
type: string
enum: [list]
data:
type: array
items:
$ref: "#/components/schemas/Model"
Model:
type: object
properties:
id:
type: string
description: Model identifier (e.g. "oah/llama-4-maverick")
example: "oah/llama-4-maverick"
object:
type: string
enum: [model]
owned_by:
type: string
example: ai-security-gateway
family:
type: string
nullable: true
description: Model family (llama, gpt, claude, gemini, etc.)
example: llama
supports_vision:
type: boolean
description: Whether the model accepts image inputs
supports_tools:
type: boolean
description: Whether the model supports function/tool calling
supports_json_mode:
type: boolean
description: Whether the model supports JSON output mode
supports_reasoning:
type: boolean
description: Whether the model supports chain-of-thought reasoning
context_window:
type: integer
nullable: true
description: Maximum context window in tokens
example: 131072
max_output_tokens:
type: integer
nullable: true
description: Maximum output tokens
example: 32768
providers:
type: array
items:
type: string
description: Available providers for this model
example: ["together", "deepinfra"]
pricing:
type: object
properties:
input_per_1m_tokens:
type: number
nullable: true
description: Input cost per 1M tokens (USD, Managed Cloud only)
example: 0.59
output_per_1m_tokens:
type: number
nullable: true
description: Output cost per 1M tokens (USD, Managed Cloud only)
example: 0.79
ChatCompletionRequest:
type: object
required: [model, messages]
properties:
model:
type: string
description: |
Model to use. Use `oah/*` prefixed virtual names for Smart Router
(e.g. "oah/llama-4-maverick") or provider-specific model IDs.
example: "oah/llama-4-maverick"
messages:
type: array
items:
$ref: "#/components/schemas/ChatMessage"
minItems: 1
stream:
type: boolean
default: false
description: If true, returns a stream of Server-Sent Events
max_tokens:
type: integer
description: Maximum tokens to generate
example: 512
temperature:
type: number
minimum: 0
maximum: 2
description: Sampling temperature
top_p:
type: number
minimum: 0
maximum: 1
description: Nucleus sampling parameter
stop:
oneOf:
- type: string
- type: array
items:
type: string
description: Stop sequences
tools:
type: array
items:
type: object
description: List of tools/functions the model can call
tool_choice:
description: Controls tool calling behavior
response_format:
type: object
properties:
type:
type: string
enum: [text, json_object]
ChatMessage:
type: object
required: [role, content]
properties:
role:
type: string
enum: [system, user, assistant, tool]
content:
oneOf:
- type: string
- type: array
items:
type: object
properties:
type:
type: string
enum: [text, image_url]
text:
type: string
image_url:
type: object
properties:
url:
type: string
description: Message content (string or array for multi-modal)
ChatCompletionResponse:
type: object
properties:
id:
type: string
example: "chatcmpl-abc123"
object:
type: string
enum: [chat.completion]
created:
type: integer
model:
type: string
choices:
type: array
items:
type: object
properties:
index:
type: integer
message:
type: object
properties:
role:
type: string
content:
type: string
finish_reason:
type: string
enum: [stop, length, tool_calls]
usage:
type: object
properties:
prompt_tokens:
type: integer
completion_tokens:
type: integer
total_tokens:
type: integer
aisg_metadata:
type: object
description: AISG-specific metadata (routing, cost, latency, DLP)
properties:
request_id:
type: string
provider:
type: string
model:
type: string
latency_ms:
type: number
dlp_latency_ms:
type: number
pii_detected:
type: boolean
cost_usd:
type: number
ErrorResponse:
type: object
properties:
detail:
oneOf:
- type: string
- type: object
properties:
error:
type: string
description: Error code
message:
type: string
description: Human-readable error message
suggested_model:
type: string
description: Suggested alternative model (if applicable)
suggested_models:
type: array
items:
type: string
description: List of suggested alternative models
docs_url:
type: string
description: Link to relevant documentation
responses:
Unauthorized:
description: Missing API key
content:
application/json:
schema:
type: object
properties:
detail:
type: string
example: "Missing API key"
Forbidden:
description: Invalid or revoked API key
content:
application/json:
schema:
type: object
properties:
detail:
type: string
example: "Invalid or revoked API key"
RateLimited:
description: Rate limit exceeded (10 requests/second)
headers:
Retry-After:
schema:
type: string
example: "1"
content:
application/json:
schema:
type: object
properties:
error:
type: string
example: rate_limit_exceeded
message:
type: string
example: "Too many requests. Limit: 10 requests/second. Please slow down and retry."