Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/e2e-canary.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ jobs:
BRAINTRUST_API_KEY: ${{ secrets.BRAINTRUST_API_KEY }}
GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }}
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
OPENROUTER_API_KEY: ${{ secrets.OPENROUTER_API_KEY }}
run: pnpm test:e2e:canary
- name: Create or update nightly canary issue
if: ${{ failure() && github.event_name == 'schedule' }}
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/integration-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ jobs:
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }}
OPENROUTER_API_KEY: ${{ secrets.OPENROUTER_API_KEY }}
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
Expand All @@ -53,6 +54,7 @@ jobs:
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }}
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
OPENROUTER_API_KEY: ${{ secrets.OPENROUTER_API_KEY }}
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
Expand All @@ -73,6 +75,7 @@ jobs:
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }}
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
OPENROUTER_API_KEY: ${{ secrets.OPENROUTER_API_KEY }}
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
Expand Down
1 change: 1 addition & 0 deletions e2e/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ Some wrappers execute inside a nested test runner rather than a single SDK call.
- `OPENAI_API_KEY`
- `ANTHROPIC_API_KEY`
- `GEMINI_API_KEY` or `GOOGLE_API_KEY`
- `OPENROUTER_API_KEY`

`wrap-claude-agent-sdk-traces` also uses `ANTHROPIC_API_KEY`, because it runs the real Claude Agent SDK against Anthropic in the same style as the existing live Anthropic wrapper coverage.

Expand Down
125 changes: 125 additions & 0 deletions e2e/helpers/openrouter-scenario.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
import {
collectAsync,
runOperation,
runTracedScenario,
} from "./provider-runtime.mjs";

const CHAT_MODEL = "openai/gpt-4.1-mini";
const EMBEDDING_MODEL = "openai/text-embedding-3-small";

export async function runOpenRouterScenario(options) {
const baseClient = new options.OpenRouter({
apiKey: process.env.OPENROUTER_API_KEY,
});
const client = options.decorateClient
? options.decorateClient(baseClient)
: baseClient;

await runTracedScenario({
callback: async () => {
await runOperation("openrouter-chat-operation", "chat", async () => {
await client.chat.send({
chatGenerationParams: {
model: CHAT_MODEL,
messages: [{ role: "user", content: "Reply with exactly OK." }],
maxTokens: 16,
temperature: 0,
},
});
});

await runOperation(
"openrouter-chat-stream-operation",
"chat-stream",
async () => {
const stream = await client.chat.send({
chatGenerationParams: {
model: CHAT_MODEL,
messages: [
{ role: "user", content: "Reply with exactly STREAM." },
],
maxTokens: 16,
stream: true,
streamOptions: {
includeUsage: true,
},
temperature: 0,
},
});
await collectAsync(stream);
},
);

await runOperation(
"openrouter-embeddings-operation",
"embeddings",
async () => {
await client.embeddings.generate({
requestBody: {
input: "braintrust tracing",
inputType: "query",
model: EMBEDDING_MODEL,
},
});
},
);

await runOperation(
"openrouter-responses-operation",
"responses",
async () => {
await client.beta.responses.send({
openResponsesRequest: {
input: "Reply with exactly OBSERVABILITY.",
maxOutputTokens: 16,
model: CHAT_MODEL,
temperature: 0,
},
});
},
);

await runOperation(
"openrouter-responses-stream-operation",
"responses-stream",
async () => {
const stream = await client.beta.responses.send({
openResponsesRequest: {
input: "Reply with exactly STREAMED RESPONSE.",
maxOutputTokens: 16,
model: CHAT_MODEL,
stream: true,
temperature: 0,
},
});
await collectAsync(stream);
},
);

await runOperation(
"openrouter-call-model-operation",
"call-model",
async () => {
const result = client.callModel({
input:
"Use the lookup_weather tool for Vienna exactly once, then answer with only the forecast.",
maxOutputTokens: 16,
maxToolCalls: 1,
model: CHAT_MODEL,
temperature: 0,
toolChoice: "required",
tools: [options.createWeatherTool()],
});

await result.getText();
},
);
},
metadata: {
openrouterSdkVersion: options.openrouterSdkVersion,
scenario: options.scenarioName,
},
projectNameBase: options.projectNameBase,
rootName: options.rootName,
});
}
Loading
Loading