Skip to content

Commit 2dcbf98

Browse files
authored
Update generated OpenRouter definitions and fix logprob schema (#5849)
1 parent 7c7d2e0 commit 2dcbf98

File tree

7 files changed

+3714
-1061
lines changed

7 files changed

+3714
-1061
lines changed

.changeset/easy-terms-warn.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@effect/ai-openrouter": minor
3+
---
4+
5+
Update generated schema definitions and apply patch fixes
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/usr/bin/env bash
2+
3+
set -euo pipefail
4+
5+
SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &> /dev/null && pwd)
6+
7+
temp_dir=$(mktemp -d)
8+
9+
cleanup() {
10+
rm -rf "${temp_dir}"
11+
}
12+
13+
trap cleanup EXIT
14+
15+
openapi_spec_url="https://spec.speakeasy.com/openrouter/sdk/open-router-chat-completions-api-with-code-samples"
16+
temp_file="${temp_dir}/openrouter.yaml"
17+
18+
touch "${temp_file}"
19+
curl "${openapi_spec_url}" > "${temp_file}"
20+
21+
echo "/**
22+
* @since 1.0.0
23+
*/" > src/Generated.ts
24+
25+
pnpm openapi-gen -s "${temp_file}" >> src/Generated.ts
26+
27+
pnpm eslint --fix src/Generated.ts
28+
29+
git apply --reject --whitespace=fix "${SCRIPT_DIR}/generated.patch"
Lines changed: 168 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,168 @@
1+
diff --git a/packages/ai/openrouter/src/Generated.ts b/packages/ai/openrouter/src/Generated.ts
2+
index 59722a09d..70484d1d7 100644
3+
--- a/packages/ai/openrouter/src/Generated.ts
4+
+++ b/packages/ai/openrouter/src/Generated.ts
5+
@@ -10,6 +10,118 @@ import * as Effect from "effect/Effect"
6+
import type { ParseError } from "effect/ParseResult"
7+
import * as S from "effect/Schema"
8+
9+
+export class CacheControlEphemeral extends S.Class<CacheControlEphemeral>("CacheControlEphemeral")({
10+
+ "type": S.Literal("ephemeral")
11+
+}) {}
12+
+
13+
+export class ReasoningDetailSummaryType extends S.Literal("reasoning.summary") {}
14+
+
15+
+export class ReasoningDetailSummaryFormat extends S.Literal("unknown", "openai-responses-v1", "anthropic-claude-v1") {}
16+
+
17+
+/**
18+
+ * Reasoning summary detail
19+
+ */
20+
+export class ReasoningDetailSummary extends S.Class<ReasoningDetailSummary>("ReasoningDetailSummary")({
21+
+ "type": ReasoningDetailSummaryType,
22+
+ "summary": S.String,
23+
+ "id": S.optionalWith(S.String, { nullable: true }),
24+
+ "format": S.optionalWith(ReasoningDetailSummaryFormat, {
25+
+ nullable: true,
26+
+ default: () => "anthropic-claude-v1" as const
27+
+ }),
28+
+ "index": S.optionalWith(S.Number, { nullable: true })
29+
+}) {}
30+
+
31+
+export class ReasoningDetailEncryptedType extends S.Literal("reasoning.encrypted") {}
32+
+
33+
+export class ReasoningDetailEncryptedFormat
34+
+ extends S.Literal("unknown", "openai-responses-v1", "anthropic-claude-v1")
35+
+{}
36+
+
37+
+/**
38+
+ * Encrypted reasoning detail
39+
+ */
40+
+export class ReasoningDetailEncrypted extends S.Class<ReasoningDetailEncrypted>("ReasoningDetailEncrypted")({
41+
+ "type": ReasoningDetailEncryptedType,
42+
+ "data": S.String,
43+
+ "id": S.optionalWith(S.String, { nullable: true }),
44+
+ "format": S.optionalWith(ReasoningDetailEncryptedFormat, {
45+
+ nullable: true,
46+
+ default: () => "anthropic-claude-v1" as const
47+
+ }),
48+
+ "index": S.optionalWith(S.Number, { nullable: true })
49+
+}) {}
50+
+
51+
+export class ReasoningDetailTextType extends S.Literal("reasoning.text") {}
52+
+
53+
+export class ReasoningDetailTextFormat extends S.Literal("unknown", "openai-responses-v1", "anthropic-claude-v1") {}
54+
+
55+
+/**
56+
+ * Text reasoning detail
57+
+ */
58+
+export class ReasoningDetailText extends S.Class<ReasoningDetailText>("ReasoningDetailText")({
59+
+ "type": ReasoningDetailTextType,
60+
+ "text": S.optionalWith(S.String, { nullable: true }),
61+
+ "signature": S.optionalWith(S.String, { nullable: true }),
62+
+ "id": S.optionalWith(S.String, { nullable: true }),
63+
+ "format": S.optionalWith(ReasoningDetailTextFormat, {
64+
+ nullable: true,
65+
+ default: () => "anthropic-claude-v1" as const
66+
+ }),
67+
+ "index": S.optionalWith(S.Number, { nullable: true })
68+
+}) {}
69+
+
70+
+/**
71+
+ * Reasoning detail information
72+
+ */
73+
+export class ReasoningDetail extends S.Union(ReasoningDetailSummary, ReasoningDetailEncrypted, ReasoningDetailText) {}
74+
+
75+
+export class FileAnnotationDetailType extends S.Literal("file") {}
76+
+
77+
+/**
78+
+ * File annotation with content
79+
+ */
80+
+export class FileAnnotationDetail extends S.Class<FileAnnotationDetail>("FileAnnotationDetail")({
81+
+ "type": FileAnnotationDetailType,
82+
+ "file": S.Struct({
83+
+ "hash": S.String,
84+
+ "name": S.optionalWith(S.String, { nullable: true }),
85+
+ "content": S.Array(S.Union(
86+
+ S.Struct({
87+
+ "type": S.Literal("text"),
88+
+ "text": S.String
89+
+ }),
90+
+ S.Struct({
91+
+ "type": S.Literal("image_url"),
92+
+ "image_url": S.Struct({
93+
+ "url": S.String
94+
+ })
95+
+ })
96+
+ ))
97+
+ })
98+
+}) {}
99+
+
100+
+export class URLCitationAnnotationDetailType extends S.Literal("url_citation") {}
101+
+
102+
+/**
103+
+ * URL citation annotation
104+
+ */
105+
+export class URLCitationAnnotationDetail extends S.Class<URLCitationAnnotationDetail>("URLCitationAnnotationDetail")({
106+
+ "type": URLCitationAnnotationDetailType,
107+
+ "url_citation": S.Struct({
108+
+ "end_index": S.Number,
109+
+ "start_index": S.Number,
110+
+ "title": S.String,
111+
+ "url": S.String,
112+
+ "content": S.optionalWith(S.String, { nullable: true })
113+
+ })
114+
+}) {}
115+
+
116+
+/**
117+
+ * Annotation information
118+
+ */
119+
+export class AnnotationDetail extends S.Union(FileAnnotationDetail, URLCitationAnnotationDetail) {}
120+
+
121+
export class OpenResponsesReasoningFormat
122+
extends S.Literal("unknown", "openai-responses-v1", "xai-responses-v1", "anthropic-claude-v1", "google-gemini-v1")
123+
{}
124+
@@ -2795,7 +2907,10 @@ export class AssistantMessage extends S.Class<AssistantMessage>("AssistantMessag
125+
"name": S.optionalWith(S.String, { nullable: true }),
126+
"tool_calls": S.optionalWith(S.Array(ChatMessageToolCall), { nullable: true }),
127+
"refusal": S.optionalWith(S.String, { nullable: true }),
128+
- "reasoning": S.optionalWith(S.String, { nullable: true })
129+
+ "reasoning": S.optionalWith(S.String, { nullable: true }),
130+
+ "reasoning_details": S.optionalWith(S.Array(ReasoningDetail), { nullable: true }),
131+
+ "images": S.optionalWith(S.Array(ChatMessageContentItemImage), { nullable: true }),
132+
+ "annotations": S.optionalWith(S.Array(AnnotationDetail), { nullable: true })
133+
}) {}
134+
135+
export class ToolResponseMessage extends S.Class<ToolResponseMessage>("ToolResponseMessage")({
136+
@@ -2913,8 +3028,8 @@ export class ChatMessageTokenLogprob extends S.Class<ChatMessageTokenLogprob>("C
137+
}) {}
138+
139+
export class ChatMessageTokenLogprobs extends S.Class<ChatMessageTokenLogprobs>("ChatMessageTokenLogprobs")({
140+
- "content": S.NullOr(S.Array(ChatMessageTokenLogprob)),
141+
- "refusal": S.NullOr(S.Array(ChatMessageTokenLogprob))
142+
+ "content": S.optionalWith(S.Array(ChatMessageTokenLogprob), { nullable: true }),
143+
+ "refusal": S.optionalWith(S.Array(ChatMessageTokenLogprob), { nullable: true })
144+
}) {}
145+
146+
export class ChatResponseChoice extends S.Class<ChatResponseChoice>("ChatResponseChoice")({
147+
@@ -2928,6 +3043,13 @@ export class ChatGenerationTokenUsage extends S.Class<ChatGenerationTokenUsage>(
148+
"completion_tokens": S.Number,
149+
"prompt_tokens": S.Number,
150+
"total_tokens": S.Number,
151+
+ "cost": S.optionalWith(S.Number, { nullable: true }),
152+
+ "cost_details": S.optionalWith(
153+
+ S.Struct({
154+
+ upstream_inference_cost: S.optionalWith(S.Number, { nullable: true })
155+
+ }),
156+
+ { nullable: true }
157+
+ ),
158+
"completion_tokens_details": S.optionalWith(
159+
S.Struct({
160+
"reasoning_tokens": S.optionalWith(S.Number, { nullable: true }),
161+
@@ -2949,6 +3071,7 @@ export class ChatGenerationTokenUsage extends S.Class<ChatGenerationTokenUsage>(
162+
163+
export class ChatResponse extends S.Class<ChatResponse>("ChatResponse")({
164+
"id": S.String,
165+
+ "provider": S.optionalWith(S.String, { nullable: true }),
166+
"choices": S.Array(ChatResponseChoice),
167+
"created": S.Number,
168+
"model": S.String,

0 commit comments

Comments
 (0)