-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathopenapi.yaml
More file actions
223 lines (223 loc) · 7.32 KB
/
Copy pathopenapi.yaml
File metadata and controls
223 lines (223 loc) · 7.32 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
openapi: 3.1.0
info:
title: Pyro API
version: 0.2.0
description: Typed prompt-injection classification for text, chats, and arbitrary JSON payloads. Each bearer key is scoped to one configured application.
servers:
- url: http://localhost:8080
security:
- bearerAuth: []
paths:
/v1/classify:
post:
summary: Classify an input and wait for a decision
operationId: classify
requestBody:
required: true
content:
application/json:
schema:
anyOf:
- $ref: "#/components/schemas/Envelope"
- type: object
additionalProperties: true
text/plain:
schema:
type: string
responses:
"200":
description: Classification decision
content:
application/json:
schema:
$ref: "#/components/schemas/Decision"
"401": { description: Invalid API key }
"403": { description: Application is disabled or the key/app cannot use the requested policy }
"413": { description: Input exceeds the selected profile limit }
"429": { description: Queue capacity or effective application/API-key rate limit has been reached }
x-cli-command: classify
x-cli-input: classification
parameters:
- name: X-Request-Id
in: header
schema:
type: string
- name: traceparent
in: header
schema:
type: string
/v1/jobs:
post:
summary: Enqueue a classification and return immediately
operationId: createClassificationJob
requestBody:
required: true
content:
application/json:
schema:
$ref: "#/components/schemas/Envelope"
responses:
"202":
description: Job accepted
x-cli-command: jobs create
x-cli-input: classification
parameters:
- name: X-Request-Id
in: header
schema:
type: string
- name: traceparent
in: header
schema:
type: string
/v1/jobs/{id}:
get:
summary: Read an asynchronous job
operationId: getClassificationJob
parameters:
- in: path
name: id
required: true
schema: { type: string }
responses:
"200": { description: Current job state }
"404": { description: Job is unknown or expired }
x-cli-command: jobs get
/v1/profiles:
get:
summary: List public profile identifiers
responses:
"200": { description: Available profiles }
operationId: listGatewayProfiles
x-cli-command: gateway profiles
/v1/events:
get:
summary: Open a real-time classification event stream
description: Upgrade to WebSocket, then send `{"type":"auth","apiKey":"..."}` within five seconds. Events are scoped to the API key's application.
operationId: streamClassificationEvents
x-websocket: true
responses:
"101": { description: WebSocket connection established }
"401": { description: Authentication failed }
x-cli-command: events
/v1/health:
get:
security: []
summary: Liveness and queue state
responses:
"200": { description: Service is alive }
operationId: getGatewayHealth
x-cli-command: health
/v1/ready:
get:
security: []
summary: Provider readiness
responses:
"200": { description: Ready }
"503": { description: Provider credentials are missing }
operationId: getGatewayReadiness
x-cli-command: ready
/metrics:
get:
security: []
summary: Prometheus metrics
responses:
"200": { description: Prometheus exposition format, content: { text/plain: { schema: { type: string } } } }
operationId: getMetrics
x-cli-command: metrics
/:
get:
operationId: getGatewayInfo
x-cli-command: gateway info
summary: Gateway discovery
security: []
responses:
"200":
description: Success
content:
application/json:
schema:
type: object
properties: {}
components:
securitySchemes:
bearerAuth:
type: http
scheme: bearer
schemas:
Envelope:
type: object
required: [ input ]
properties:
input: {}
profile: { type: string, default: default }
metadata:
type: object
additionalProperties: true
labels:
type: object
maxProperties: 20
description: Searchable request context such as a session URL, tenant, or environment.
propertyNames: { pattern: "^[A-Za-z0-9_.-]{1,64}$" }
additionalProperties: { type: string, maxLength: 2048 }
DetectorResult:
type: object
required: [ id, name, probability, weightedProbability ]
properties:
id: { type: string }
name: { type: string }
probability: { type: number, minimum: 0, maximum: 1 }
weightedProbability: { type: number, minimum: 0, maximum: 1 }
Decision:
type: object
required: [ id, createdAt, profileId, verdict, action, risk, confidence, reason, detectors, model, provider, latencyMs, queueMs ]
properties:
id: { type: string, description: Server-generated decision identifier }
requestId: { type: string, description: Valid incoming X-Request-Id or a generated request identifier }
createdAt: { type: string, format: date-time }
traceId: { type: string, description: W3C trace identifier }
profileId: { type: string }
verdict: { enum: [ safe, suspicious, unsafe, indeterminate ] }
action: { enum: [ allow, review, block ] }
risk: { type: number, minimum: 0, maximum: 1 }
confidence: { type: number, minimum: 0, maximum: 1 }
reason: { type: string }
detectors:
type: array
items: { $ref: "#/components/schemas/DetectorResult" }
model: { type: string }
provider: { type: string }
latencyMs: { type: number }
queueMs: { type: number }
labels:
type: object
additionalProperties: { type: string }
timings:
type: object
properties:
providerMs: { type: number }
policyMs: { type: number }
totalMs: { type: number }
usage:
type: object
description: Provider token usage and actual billed cost when reported. Local decisions report zero cost.
properties:
inputTokens: { type: integer, minimum: 0 }
outputTokens: { type: integer, minimum: 0 }
cost:
type: object
required: [ amount, currency ]
properties:
amount: { type: number, minimum: 0 }
currency: { type: string, pattern: "^[A-Z]{3}$" }
shadows:
type: array
description: Non-enforcing results from configured shadow policies.
items:
type: object
properties:
profileId: { type: string }
verdict: { enum: [ safe, suspicious, unsafe, indeterminate ] }
action: { enum: [ allow, review, block ] }
risk: { type: number }
changed: { type: boolean }