-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathopenapi.yaml
More file actions
177 lines (177 loc) · 6.09 KB
/
Copy pathopenapi.yaml
File metadata and controls
177 lines (177 loc) · 6.09 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
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:
oneOf:
- $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 }
/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
/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 }
/v1/profiles:
get:
summary: List public profile identifiers
responses:
"200": { description: Available 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 }
/v1/health:
get:
security: []
summary: Liveness and queue state
responses:
"200": { description: Service is alive }
/v1/ready:
get:
security: []
summary: Provider readiness
responses:
"200": { description: Ready }
"503": { description: Provider credentials are missing }
/metrics:
get:
security: []
summary: Prometheus metrics
responses:
"200": { description: Prometheus exposition format }
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 }