Skip to content

feat: add multimedia endpoint support (image, TTS, transcription, video)#101

Open
AlemTuzlak wants to merge 5 commits intomainfrom
worktree-sharded-rolling-tide
Open

feat: add multimedia endpoint support (image, TTS, transcription, video)#101
AlemTuzlak wants to merge 5 commits intomainfrom
worktree-sharded-rolling-tide

Conversation

@AlemTuzlak
Copy link
Copy Markdown
Contributor

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 promptuserMessage
/v1beta/models/{model}:predict POST Gemini Imagen instances[0].promptuserMessage
/v1/audio/speech POST OpenAI inputuserMessage
/v1/audio/transcriptions POST OpenAI (multipart) match.endpoint only
/v1/videos POST OpenAI promptuserMessage
/v1/videos/{id} GET OpenAI Stored video ID

Test plan

  • Image generation: single, multiple, base64, Gemini Imagen format
  • TTS: correct Content-Type for mp3/opus, default format fallback
  • Transcription: simple JSON and verbose_json with words/segments
  • Video: create + status check, processing state, 404 for unknown ID
  • X-Test-Id isolation for image endpoint
  • Endpoint cross-matching prevention (image vs chat)
  • Convenience methods (onImage, onSpeech, onTranscription, onVideo)
  • Backfill: endpoint: "chat" and endpoint: "embedding" fixtures match existing handlers
  • Full suite: 2216 tests pass, 0 failures

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new bot commented Apr 10, 2026

Open in StackBlitz

npm i https://pkg.pr.new/@copilotkit/aimock@101

commit: 1f2d451

Copy link
Copy Markdown
Contributor

@jpr5 jpr5 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review — Multimedia Endpoint Support

Well-structured PR. All 4 handlers follow consistent patterns, endpoint backfill is correct across all existing handlers, tests are strong (575 lines with specific assertions). One medium finding, two low.

Medium

Fixtures without endpoint match multimedia requests, then 500 at type guard (router.ts:44-48)

Endpoint filtering is one-directional: fixtures WITH endpoint are restricted, but fixtures WITHOUT endpoint match ANY request type. A user with a generic chat fixture:

mock.addFixture({ match: { userMessage: "guitar" }, response: { content: "Chat about guitars" } });

This matches image requests for "guitar". handleImages matches it, then isImageResponse(response) fails → 500. The test only verifies the reverse direction (image fixture doesn't match chat).

Fix: when a request has _endpointType and the matched fixture has no endpoint, verify the response type is compatible with the endpoint before returning the match. Or make filtering bidirectional.

Low

extractFormField regex on binary multipart data (transcription.ts:15-22) — readBody converts binary to UTF-8 string. If file part appears before text fields, mangled bytes could theoretically match the regex. Extremely unlikely with real audio but fragile. A boundary-delimited parser would be more robust.

_endpointType not a declared field (types.ts) — stored via index signature, no type safety. Adding _endpointType?: string to ChatCompletionRequest would catch typos.

Clean

  • Image gen (OpenAI + Gemini Imagen), TTS, transcription, video create/poll all correct
  • matchFixture endpoint filtering works for the designed direction
  • Convenience methods (onImage, onSpeech, etc.) wire correctly
  • Video state map with X-Test-Id isolation is correct
  • Backfill of _endpointType on all existing handlers is consistent

🤖 Reviewed with Claude Code

…iltering

New response types (ImageResponse, AudioResponse, TranscriptionResponse,
VideoResponse) with type guards. matchFixture now filters by endpoint
bidirectionally: fixtures with endpoint only match that type, and
multimedia requests skip generic fixtures with incompatible response types.
Image generation (OpenAI + Gemini Imagen), text-to-speech with format
support, audio transcription with multipart parsing, video generation
with async status polling via in-memory state map.
Register all multimedia routes in server.ts. Add onImage/onSpeech/
onTranscription/onVideo convenience methods on LLMock. Backfill
_endpointType on all existing handlers (chat + embedding).
20 integration tests (image gen, TTS, transcription, video create/poll,
X-Test-Id isolation, cross-matching prevention, convenience methods,
endpoint backfill) + 12 unit tests for type guards and matchFixture
endpoint filtering.
@jpr5 jpr5 force-pushed the worktree-sharded-rolling-tide branch from 3d68797 to bacfac4 Compare April 10, 2026 18:32
New doc pages for image generation, TTS, transcription, and video.
Updated fixtures page, index feature list, sidebar nav, comparison
table (all competitors lack multimedia), and competitive drift
detection keywords.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants