Repository navigation
Expand file tree
/
Copy pathopenapi.yaml
More file actions
352 lines (352 loc) · 10.3 KB
/
Copy pathopenapi.yaml
File metadata and controls
352 lines (352 loc) · 10.3 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
openapi: 3.0.3
info:
title: ShareLLM inference gateway
version: 0.1.0
description: |
Implemented subset of the Ollama inference API, OpenAI-compatible inference,
and ShareLLM queue/worker extensions. The original Ollama specification has
additional endpoints which ShareLLM does not implement. Streaming is a
delayed, single final event rather than token-by-token.
externalDocs:
description: Original upstream Ollama API definition
url: https://github.com/ollama/ollama/blob/main/docs/openapi.yaml
servers:
- url: /
security:
- bearerAuth: []
paths:
/api/chat:
post:
summary: Chat using an available Ollama worker
operationId: ollamaChat
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/ChatRequest'
responses:
'200':
description: Chat response or delayed single NDJSON event
content:
application/json:
schema:
type: object
additionalProperties: true
application/x-ndjson:
schema:
type: string
'504':
$ref: '#/components/responses/TimedOut'
/api/generate:
post:
summary: Generate using an available Ollama worker
operationId: ollamaGenerate
requestBody:
required: true
content:
application/json:
schema:
type: object
required: [model]
properties:
model: {type: string}
prompt: {type: string}
stream: {type: boolean, default: true}
additionalProperties: true
responses:
'200':
description: Generate response or delayed single NDJSON event
content:
application/json:
schema: {type: object, additionalProperties: true}
application/x-ndjson:
schema: {type: string}
'504':
$ref: '#/components/responses/TimedOut'
/api/embed:
post:
summary: Ollama current embedding API
requestBody:
required: true
content:
application/json:
schema:
type: object
required: [model, input]
properties:
model: {type: string}
input: {}
additionalProperties: true
responses:
'200':
description: Embeddings result
content:
application/json:
schema: {type: object, additionalProperties: true}
/api/embeddings:
post:
summary: Ollama legacy embeddings API
requestBody:
required: true
content:
application/json:
schema:
type: object
required: [model, prompt]
properties:
model: {type: string}
prompt: {type: string}
additionalProperties: true
responses:
'200':
description: Embedding result
/api/show:
post:
summary: Get local worker model information
requestBody:
required: true
content:
application/json:
schema:
type: object
required: [model]
properties:
model: {type: string}
responses:
'200':
description: Native model information
/api/tags:
get:
summary: Online advertised model names (synthetic metadata)
responses:
'200':
description: Online model list
content:
application/json:
schema: {type: object, additionalProperties: true}
/api/version:
get:
summary: ShareLLM version
responses:
'200':
description: ShareLLM version string
/v1/chat/completions:
post:
summary: OpenAI-compatible chat
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/ChatRequest'
responses:
'200':
description: Chat completion or delayed single SSE chunk
content:
application/json:
schema: {type: object, additionalProperties: true}
text/event-stream:
schema: {type: string}
/v1/completions:
post:
summary: OpenAI-compatible text completion (string prompts)
requestBody:
required: true
content:
application/json:
schema:
type: object
required: [model, prompt]
properties:
model: {type: string}
prompt: {type: string}
stream: {type: boolean, default: false}
additionalProperties: true
responses:
'200':
description: Text completion
/v1/embeddings:
post:
summary: OpenAI-compatible vector embeddings
requestBody:
required: true
content:
application/json:
schema:
type: object
required: [model, input]
properties:
model: {type: string}
input: {}
additionalProperties: true
responses:
'200':
description: OpenAI embeddings
/v1/models:
get:
summary: Online models in OpenAI format
responses:
'200':
description: OpenAI model list
/sharellm/requests:
post:
summary: Enqueue asynchronously
requestBody:
required: true
content:
application/json:
schema:
type: object
required: [endpoint, request]
properties:
endpoint:
type: string
enum: [chat, generate, embed, embeddings, show]
request:
type: object
required: [model]
additionalProperties: true
responses:
'202':
description: Queued; contains ID and Location header
content:
application/json:
schema: {type: object, additionalProperties: true}
/sharellm/requests/{id}:
get:
summary: Poll durable result using same owner bearer key
parameters:
- name: id
in: path
required: true
schema: {type: string, format: uuid}
responses:
'202':
description: Queued or leased
'200':
description: Completed; ShareLLM result envelope contains native Ollama JSON
'502':
description: Terminal inference failure
'404':
description: Unknown or other owner
/internal/workers/register:
post:
summary: Register or update worker/model inventory
requestBody:
required: true
content:
application/json:
schema:
type: object
required: [clientId, models]
properties:
clientId: {type: string}
models: {type: array, items: {type: string}}
responses:
'200': {description: Registered}
/internal/workers/heartbeat:
post:
summary: Renew worker and its active lease
requestBody:
required: true
content:
application/json:
schema:
type: object
required: [clientId]
properties:
clientId: {type: string}
responses:
'200': {description: Heartbeat acknowledged}
/internal/jobs/claim:
get:
summary: Poll and atomically lease a request
parameters:
- name: clientId
in: query
required: true
schema: {type: string}
- name: waitSeconds
in: query
schema: {type: integer, default: 15}
responses:
'200':
description: Assigned job including leaseToken
content:
application/json:
schema: {type: object, additionalProperties: true}
'204': {description: No matching job during wait window}
/internal/jobs/{id}/complete:
post:
summary: Deliver result with lease fencing token
parameters:
- name: id
in: path
required: true
schema: {type: string, format: uuid}
requestBody:
required: true
content:
application/json:
schema:
type: object
required: [clientId, leaseToken, response]
properties:
clientId: {type: string}
leaseToken: {type: string, format: uuid}
response: {type: object, additionalProperties: true}
responses:
'200': {description: Result accepted}
'409': {description: Lease expired or already completed}
/internal/jobs/{id}/fail:
post:
summary: Fail and retry or terminally fail job
parameters:
- name: id
in: path
required: true
schema: {type: string, format: uuid}
requestBody:
required: true
content:
application/json:
schema:
type: object
required: [clientId, leaseToken, error]
properties:
clientId: {type: string}
leaseToken: {type: string, format: uuid}
error: {type: string}
responses:
'200': {description: Failure acknowledged}
'409': {description: Lease expired or already completed}
components:
securitySchemes:
bearerAuth:
type: http
scheme: bearer
description: Public endpoints use a public owner key; internal endpoints use the separate worker key.
responses:
TimedOut:
description: Synchronous wait elapsed; Location and X-ShareLLM-Request-Id allow later GET.
headers:
Location: {schema: {type: string}}
X-ShareLLM-Request-Id: {schema: {type: string, format: uuid}}
schemas:
ChatRequest:
type: object
required: [model, messages]
properties:
model: {type: string}
messages:
type: array
items:
type: object
properties:
role: {type: string}
content: {}
additionalProperties: true
stream: {type: boolean, default: true}
tools: {type: array, items: {type: object}}
additionalProperties: true