Add TrustedRouter custom OpenAI client example#2252
Conversation
|
|
This PR is from an external contributor and must be approved by a stagehand team member with write access before CI can run. |
|
Marked this ready for review. This is a docs/example-only TrustedRouter setup using the OpenAI-compatible endpoint at https://api.trustedrouter.com/v1; happy to adjust the example placement if the Stagehand team prefers another docs location. |
There was a problem hiding this comment.
No issues found across 2 files
Confidence score: 5/5
- Automated review surfaced no issues in the provided summaries.
- No files require special attention.
Architecture diagram
sequenceDiagram
participant User as "User Script"
participant Stagehand as Stagehand
participant CustomClient as "CustomOpenAIClient"
participant TR as "TrustedRouter API"
Note over User,TR: NEW: TrustedRouter custom OpenAI client flow
User->>Stagehand: new Stagehand({ llmClient: CustomOpenAIClient })
User->>Stagehand: stagehand.init()
User->>Stagehand: stagehand.act("click on the 'new' link")
Stagehand->>CustomClient: send("click on the 'new' link")
CustomClient->>TR: POST /v1/chat/completions\n(model: trustedrouter/zdr)
TR-->>CustomClient: completion
CustomClient-->>Stagehand: action result
Stagehand-->>User: done
User->>Stagehand: stagehand.extract("Extract the top 3 stories...")
Stagehand->>CustomClient: extract request
CustomClient->>TR: POST /v1/chat/completions\n(model: trustedrouter/zdr)
TR-->>CustomClient: structured output
CustomClient-->>Stagehand: parsed extraction
Stagehand-->>User: headlines
User->>Stagehand: stagehand.close()
Summary
https://api.trustedrouter.com/v1as the base URLtrustedrouter/zdrmodel alias for privacy-sensitive agent workloadsWhy
TrustedRouter is useful for workflows that involve private code, customer data, or other sensitive context. It provides open-source, verifiable attested routing and does not log prompts or outputs by default.
Validation
git diff --checkSummary by cubic
Add a runnable TrustedRouter custom client example and document it in the README. Enables privacy-sensitive Stagehand workflows using
trustedrouter/zdrviahttps://api.trustedrouter.com/v1.packages/core/examples/custom-client-trustedrouter.tsshowingCustomOpenAIClientwithtrustedrouter/zdrandTRUSTEDROUTER_API_KEY.Written for commit 7ddda6c. Summary will update on new commits.