Open History to see the last commit
1import { test, expect } from './fixtures'
2
3type JournalEntry = {
4 headers?: Record<string, string>
5 body: {
6 response_format?: Record<string, unknown>
7 } | null
8}
9
10test.describe('openrouter — json_object structured output', () => {
11 test.beforeEach(async ({ request, aimockPort }) => {
12 await request.delete(`http://127.0.0.1:${aimockPort}/v1/_requests`)
13 })
14
15 test('preserves json_object through the SDK wire path (#1005)', async ({
16 request,
17 aimockPort,
18 testId,
19 }) => {
20 const response = await request.post(
21 `/api/openrouter-json-object-wire?testId=${encodeURIComponent(testId)}`,
22 )
23 expect(response.ok()).toBe(true)
24 expect(await response.json()).toEqual({
25 ok: true,
26 result: { name: 'Alice', age: 30 },
27 })
28
29 const journalResponse = await request.get(
30 `http://127.0.0.1:${aimockPort}/v1/_requests`,
31 )
32 const entries = (await journalResponse.json()) as Array<JournalEntry>
33 const captured = entries.find(
34 (entry) => entry.headers?.['x-test-id'] === testId,
35 )
36
37 expect(captured?.body?.response_format).toEqual({
38 type: 'json_object',
39 })
40 })
41})