Commit 752966a
authored
feat: add multimedia endpoint support (image, TTS, transcription, video) (#101)
## Summary
- Add four new multimedia endpoint types: image generation
(`/v1/images/generations`, `/v1beta/models/{model}:predict`),
text-to-speech (`/v1/audio/speech`), audio transcription
(`/v1/audio/transcriptions`), and video generation (`/v1/videos`,
`/v1/videos/{id}`)
- Add `match.endpoint` field to `FixtureMatch` for isolating fixtures by
endpoint type, preventing cross-matching (e.g., image fixtures won't
match chat requests)
- Add convenience methods (`onImage`, `onSpeech`, `onTranscription`,
`onVideo`) on `LLMock` and backfill `_endpointType` on all existing
handlers
## New Endpoints
| Route | Method | Format | Match field |
|-------|--------|--------|-------------|
| `/v1/images/generations` | POST | OpenAI | `prompt` → `userMessage` |
| `/v1beta/models/{model}:predict` | POST | Gemini Imagen |
`instances[0].prompt` → `userMessage` |
| `/v1/audio/speech` | POST | OpenAI | `input` → `userMessage` |
| `/v1/audio/transcriptions` | POST | OpenAI (multipart) |
`match.endpoint` only |
| `/v1/videos` | POST | OpenAI | `prompt` → `userMessage` |
| `/v1/videos/{id}` | GET | OpenAI | Stored video ID |
## Test plan
- [x] Image generation: single, multiple, base64, Gemini Imagen format
- [x] TTS: correct Content-Type for mp3/opus, default format fallback
- [x] Transcription: simple JSON and verbose_json with words/segments
- [x] Video: create + status check, processing state, 404 for unknown ID
- [x] X-Test-Id isolation for image endpoint
- [x] Endpoint cross-matching prevention (image vs chat)
- [x] Convenience methods (onImage, onSpeech, onTranscription, onVideo)
- [x] Backfill: `endpoint: "chat"` and `endpoint: "embedding"` fixtures
match existing handlers
- [x] Full suite: 2216 tests pass, 0 failures34 files changed
Lines changed: 3388 additions & 12 deletions
File tree
- charts/aimock
- docs
- fixtures
- images
- speech
- transcription
- video
- scripts
- src
- __tests__
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
3 | 16 | | |
4 | 17 | | |
5 | 18 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
| 5 | + | |
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| |||
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
| 46 | + | |
46 | 47 | | |
47 | 48 | | |
48 | 49 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
| 6 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
162 | 162 | | |
163 | 163 | | |
164 | 164 | | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
165 | 185 | | |
166 | 186 | | |
167 | 187 | | |
| |||
239 | 259 | | |
240 | 260 | | |
241 | 261 | | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
242 | 266 | | |
243 | 267 | | |
244 | 268 | | |
| |||
0 commit comments