Combine anthropic claude with openai fallback router
Multi-model chat with one client endpoint
Primary Anthropic Messages step plus OpenAI fallback step in one pipeline. For "combine anthropic claude with openai fallback router", store ANTHROPIC_API_KEY, OPENAI_API_KEY in Secret Vault, call https://api.anthropic.com/v1/messages from a Worker, and let Frontend / Web hit only https://realcomposer.com/v1/workspace/combine-anthropic-with-openai-fallback with an rc_live_ client token. POST upstream calls are not stored in caches.default; clients must send JSON bodies and headers forward unchanged.
Serial Anthropic and OpenAI calls slow Frontend / Web pages
Each extra Anthropic and OpenAI hop adds hundreds of milliseconds and another OAuth refresh path your UI must manage.
- One slow upstream blocking an entire page
- Partial failures leaving UI in inconsistent states
- Duplicate auth refresh logic per service
How RealComposer Solves This at the Edge
Add vault secrets for this pipeline
Store ANTHROPIC_API_KEY, OPENAI_API_KEY in the vault. Frontend / Web never embeds the raw secret, only a revocable rc_live_ client token.
Target the real upstream URL
Configure headersTemplate to inject vault secrets, target https://api.anthropic.com/v1/messages, and Add output mapping fields that mirror the JSON contract your screen already expects.
Call from Frontend / Web
Allowed origins on the token should list every Frontend / Web host that calls this URL.
const res = await fetch('https://realcomposer.com/v1/workspace/combine-anthropic-with-openai-fallback', {
headers: { Authorization: 'Bearer rc_live_your_token' }
});
{
"requestId": "req_combine-",
"upstreamLatencyMs": 142,
"audit": {
"region": "edge",
"trace": "combine-anthropic-with-openai-fallback"
},
"payload": {
"id": "sample_id",
"status": "active",
"nested": {
"tags": [
"demo"
],
"internal": true
},
"unused_blob": {
"foo": "bar",
"bar": "baz"
}
}
}
{
"anthropic_role": "sample",
"anthropic_model": "sample",
"openai_reply": "sample",
"openai_tokens": "sample"
}
Recipe Specs
- HTTP method
- POST
- Upstream calls
- 2
- Edge cache TTL
- No caching
- Client auth
- Restricted client token
- Mapped output fields
- 4
- Payload
- 257 B to 103 B (-60%)
curl -X POST "https://realcomposer.com/v1/workspace/combine-anthropic-with-openai-fallback" \
-H "Authorization: Bearer rc_live_client_token" \
-H "Content-Type: application/json" \
-d '{"model":"example"}'Developer Questions & Troubleshooting
Can Frontend / Web call Anthropic without holding the production key?
Use scoped tokens where the vendor allows them on combine-anthropic-with-openai-fallback. Admin keys stay {{secrets.*}} references only.
How do I forward JSON bodies to POST upstreams?
combine-anthropic-with-openai-fallback POST steps bypass caches.default even if cacheTtlSeconds is set in the dashboard.
How do I rotate upstream credentials?
Rotate vault secrets for combine-anthropic-with-openai-fallback anytime; clients keep the same rc_live_ token.
Sources & Definitions Used in This Answer
- DefinitionLLM Gateway (AI Gateway)
- DefinitionGraceful Degradation
- DefinitionAPI Failover
- DefinitionAI Agent API
- DefinitionLLM Tool Calling
- Stack guideWeb Frontends safe & unsafe practices
- Stack guideAnthropic safe & unsafe practices
- Stack guideOpenAI safe & unsafe practices
- Official docsWeb Frontends documentation
- Official docsAnthropic documentation
- Official docsOpenAI documentation
Deploy this Frontend / Web + Anthropic, OpenAI Recipe
Clone this pre-configured pipeline into your RealComposer workspace in one click. We pre-populate upstream URLs, headers, and mapping rules.