File size: 7,112 Bytes
cd8bd0a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
// AUTO-GENERATED by scripts/docs/gen-openapi-module.mjs — DO NOT EDIT MANUALLY
// Regenerate with: node scripts/docs/gen-openapi-module.mjs
//
// Source of truth: docs/openapi.yaml
//
// The Api Explorer consumes `OPENAPI_ENDPOINTS`; the spec metadata
// (`OPENAPI_VERSION`, `OPENAPI_TITLE`) is surfaced in the page header.

export interface OpenApiEndpoint {
  /** Path template — may contain `{param}` placeholders. */
  path: string;
  /** HTTP method in upper case (GET / POST / PUT / DELETE / PATCH / ...). */
  method: string;
  /** Short one-line summary from the spec. */
  summary: string;
  /** Long-form description (markdown is allowed). */
  description: string;
  /** Primary tag — used for sidebar grouping in the Api Explorer. */
  tag: string;
  /** All tags declared on the operation. */
  tags: string[];
  /** `true` when the operation declares a non-empty `security` array. */
  requiresAuth: boolean;
  /** `true` when the operation declares a `requestBody`. */
  hasRequestBody: boolean;
}

export const OPENAPI_VERSION = "3.8.35";
export const OPENAPI_TITLE = "OmniRoute API";

export const OPENAPI_ENDPOINTS: OpenApiEndpoint[] = [
  {
    path: "/api/v1",
    method: "GET",
    summary: "API v1 root endpoint",
    description: "Returns basic API info and status.",
    tag: "System",
    tags: ["System"],
    requiresAuth: true,
    hasRequestBody: false,
  },
  {
    path: "/api/v1/api/chat",
    method: "POST",
    summary: "Ollama-compatible chat endpoint",
    description: "Provides compatibility with Ollama's /api/chat format.",
    tag: "Chat",
    tags: ["Chat"],
    requiresAuth: true,
    hasRequestBody: true,
  },
  {
    path: "/api/v1/audio/speech",
    method: "POST",
    summary: "Generate speech audio",
    description: "Text-to-speech endpoint. Routes to configured TTS providers.",
    tag: "Audio",
    tags: ["Audio"],
    requiresAuth: true,
    hasRequestBody: true,
  },
  {
    path: "/api/v1/audio/transcriptions",
    method: "POST",
    summary: "Transcribe audio",
    description: "Audio-to-text transcription endpoint.",
    tag: "Audio",
    tags: ["Audio"],
    requiresAuth: true,
    hasRequestBody: true,
  },
  {
    path: "/api/v1/chat/completions",
    method: "POST",
    summary: "Create chat completion",
    description: "OpenAI-compatible chat completions endpoint. Routes to configured providers.",
    tag: "Chat",
    tags: ["Chat"],
    requiresAuth: true,
    hasRequestBody: true,
  },
  {
    path: "/api/v1/embeddings",
    method: "POST",
    summary: "Create embeddings",
    description: "",
    tag: "Embeddings",
    tags: ["Embeddings"],
    requiresAuth: true,
    hasRequestBody: true,
  },
  {
    path: "/api/v1/images/generations",
    method: "POST",
    summary: "Generate images",
    description: "",
    tag: "Images",
    tags: ["Images"],
    requiresAuth: true,
    hasRequestBody: true,
  },
  {
    path: "/api/v1/messages",
    method: "POST",
    summary: "Create message (Anthropic-compatible)",
    description: "Anthropic Messages API endpoint. Routes to Claude providers.",
    tag: "Messages",
    tags: ["Messages"],
    requiresAuth: true,
    hasRequestBody: true,
  },
  {
    path: "/api/v1/messages/count_tokens",
    method: "POST",
    summary: "Count tokens for a message",
    description: "",
    tag: "Messages",
    tags: ["Messages"],
    requiresAuth: true,
    hasRequestBody: true,
  },
  {
    path: "/api/v1/models",
    method: "GET",
    summary: "List available models",
    description: "Returns all models available across configured providers.",
    tag: "Models",
    tags: ["Models"],
    requiresAuth: true,
    hasRequestBody: false,
  },
  {
    path: "/api/v1/moderations",
    method: "POST",
    summary: "Create moderation",
    description: "Content moderation endpoint. Routes to configured moderation providers.",
    tag: "Moderations",
    tags: ["Moderations"],
    requiresAuth: true,
    hasRequestBody: true,
  },
  {
    path: "/api/v1/providers/{provider}/chat/completions",
    method: "POST",
    summary: "Create chat completion (provider-specific)",
    description: "Routes to a specific provider by name.",
    tag: "Chat",
    tags: ["Chat"],
    requiresAuth: true,
    hasRequestBody: true,
  },
  {
    path: "/api/v1/providers/{provider}/embeddings",
    method: "POST",
    summary: "Create embeddings (provider-specific)",
    description: "",
    tag: "Embeddings",
    tags: ["Embeddings"],
    requiresAuth: true,
    hasRequestBody: true,
  },
  {
    path: "/api/v1/providers/{provider}/images/generations",
    method: "POST",
    summary: "Generate images (provider-specific)",
    description: "",
    tag: "Images",
    tags: ["Images"],
    requiresAuth: true,
    hasRequestBody: true,
  },
  {
    path: "/api/v1/providers/{provider}/models",
    method: "GET",
    summary: "List models for a specific provider",
    description: "Returns only models for the selected provider with provider prefix removed from each model id.",
    tag: "Models",
    tags: ["Models"],
    requiresAuth: true,
    hasRequestBody: false,
  },
  {
    path: "/api/v1/rerank",
    method: "POST",
    summary: "Rerank documents",
    description: "Document reranking endpoint.",
    tag: "Rerank",
    tags: ["Rerank"],
    requiresAuth: true,
    hasRequestBody: true,
  },
  {
    path: "/api/v1/responses",
    method: "POST",
    summary: "Create response (OpenAI Responses API)",
    description: "OpenAI Responses API endpoint.",
    tag: "Responses",
    tags: ["Responses"],
    requiresAuth: true,
    hasRequestBody: true,
  },
  {
    path: "/api/v1/ws",
    method: "GET",
    summary: "Chat completion over WebSocket (handshake + upgrade)",
    description: "OpenAI-compatible chat over a WebSocket connection. `GET` with `?handshake=1` returns the connection descriptor (auth path, message protocol and live-event channels) as JSON; a plain `GET` without an Upgrade returns `426 Upgrade Required`. After upgrading, the client exchanges JSON frames — `{type:\"request\", id, payload:{model, messages}}` to start a completion and `{type:\"cancel\", id}` to abort it. A separate live channel (default port `LIVE_WS_PORT=20129`, path `/live`) streams dashboard events on the `requests`, `combo` and `credentials` topics with a 15s heartbeat. Requires an API key.",
    tag: "Chat",
    tags: ["Chat"],
    requiresAuth: true,
    hasRequestBody: false,
  },
  {
    path: "/api/v1beta/models",
    method: "GET",
    summary: "List models (Gemini format)",
    description: "Returns models in Gemini v1beta format for native SDK compatibility",
    tag: "Models",
    tags: ["Models"],
    requiresAuth: true,
    hasRequestBody: false,
  },
  {
    path: "/api/v1beta/models/{path}",
    method: "POST",
    summary: "Gemini generateContent",
    description: "Gemini-compatible generateContent endpoint",
    tag: "Models",
    tags: ["Models"],
    requiresAuth: true,
    hasRequestBody: true,
  },
];

export const OPENAPI_TAGS: string[] = Array.from(
  new Set(OPENAPI_ENDPOINTS.map((endpoint) => endpoint.tag))
).sort();