Summary
Add integration tests for the new OpenRouter media generation features across all three SDKs. Tests should be runnable with a real API key and skipped gracefully when no key is available.
Test Matrix
| Modality |
Model (cheap) |
SDK |
Expected Result |
| Video (text-to-video) |
alibaba/wan-2.6 ($0.04/s) |
Python, TS, Go |
MP4 file in response |
| Video (image-to-video) |
alibaba/wan-2.7 |
Python |
MP4 from first_frame |
| Image |
google/gemini-2.5-flash-image |
Python, TS, Go |
PNG/base64 in response |
| Audio output |
openai/gpt-audio |
Python, TS, Go |
WAV/MP3 audio data |
Test Structure
Python (sdk/python/tests/test_openrouter_media.py)
import pytest
import os
pytestmark = [
pytest.mark.integration,
pytest.mark.skipif(
not os.getenv("OPENROUTER_API_KEY"),
reason="OPENROUTER_API_KEY not set"
),
]
@pytest.mark.asyncio
async def test_video_text_to_video():
"""Generate a short video from text prompt."""
provider = OpenRouterProvider(api_key=os.environ["OPENROUTER_API_KEY"])
result = await provider.generate_video(
"A simple red ball bouncing",
model="alibaba/wan-2.6",
duration=4,
resolution="480p",
)
assert result.has_video or len(result.files) > 0
assert result.files[0].mime_type == "video/mp4"
@pytest.mark.asyncio
async def test_video_timeout_handling():
"""Verify timeout raises appropriate error."""
provider = OpenRouterProvider(api_key=os.environ["OPENROUTER_API_KEY"])
with pytest.raises((TimeoutError, asyncio.TimeoutError)):
await provider.generate_video(
"A complex scene",
model="alibaba/wan-2.6",
timeout=1.0, # Impossibly short
)
@pytest.mark.asyncio
async def test_image_generation():
"""Generate image via OpenRouter."""
provider = OpenRouterProvider(api_key=os.environ["OPENROUTER_API_KEY"])
result = await provider.generate_image(
"A simple red circle on white background",
model="google/gemini-2.5-flash-image",
)
assert len(result.images) > 0
@pytest.mark.asyncio
async def test_audio_generation():
"""Generate audio via OpenRouter."""
provider = OpenRouterProvider(api_key=os.environ["OPENROUTER_API_KEY"])
result = await provider.generate_audio(
"Hello world",
model="openai/gpt-audio",
voice="alloy",
format="wav",
)
assert result.audio is not None
TypeScript (sdk/typescript/src/ai/__tests__/openrouter-media.test.ts)
Same test cases using vitest/jest with describe.skipIf(!process.env.OPENROUTER_API_KEY).
Go (sdk/go/ai/openrouter_media_test.go)
Same test cases using testing.T with t.Skip("OPENROUTER_API_KEY not set").
Dependencies
Files
| File |
SDK |
sdk/python/tests/test_openrouter_media.py |
Python |
sdk/typescript/src/ai/__tests__/openrouter-media.test.ts |
TypeScript |
sdk/go/ai/openrouter_media_test.go |
Go |
Acceptance Criteria
Notes for Contributors
Severity: MEDIUM
Use the cheapest models for testing: alibaba/wan-2.6 for video ($0.04/sec, ~4 sec clip = $0.16), google/gemini-2.5-flash-image for images. Keep video prompts simple and durations short (4 seconds max) to minimize cost and generation time.
Mark all tests as @pytest.mark.integration (Python), or equivalent in TS/Go, so they don't run in unit test CI by default.
Summary
Add integration tests for the new OpenRouter media generation features across all three SDKs. Tests should be runnable with a real API key and skipped gracefully when no key is available.
Test Matrix
alibaba/wan-2.6($0.04/s)alibaba/wan-2.7google/gemini-2.5-flash-imageopenai/gpt-audioTest Structure
Python (
sdk/python/tests/test_openrouter_media.py)TypeScript (
sdk/typescript/src/ai/__tests__/openrouter-media.test.ts)Same test cases using vitest/jest with
describe.skipIf(!process.env.OPENROUTER_API_KEY).Go (
sdk/go/ai/openrouter_media_test.go)Same test cases using
testing.Twitht.Skip("OPENROUTER_API_KEY not set").Dependencies
Files
sdk/python/tests/test_openrouter_media.pysdk/typescript/src/ai/__tests__/openrouter-media.test.tssdk/go/ai/openrouter_media_test.goAcceptance Criteria
OPENROUTER_API_KEYnot setNotes for Contributors
Severity: MEDIUM
Use the cheapest models for testing:
alibaba/wan-2.6for video ($0.04/sec, ~4 sec clip = $0.16),google/gemini-2.5-flash-imagefor images. Keep video prompts simple and durations short (4 seconds max) to minimize cost and generation time.Mark all tests as
@pytest.mark.integration(Python), or equivalent in TS/Go, so they don't run in unit test CI by default.