Repository navigation
Let OpenAI Responses and Chat clients use any provider - #23
Merged
Merged
Conversation
Port CPA's gemini/claude translator: Anthropic Messages become Gemini generateContent (system instruction, turns, function calls and responses, images, tools, tool choice, thinking), and Gemini answers, streamed or whole, become Anthropic events and messages. Google's default safety settings stay in place instead of being switched off.
Port CPA's claude/openai/chat-completions translator: Chat Completions requests become Anthropic Messages (system and developer prompts, turns, tool calls and results, images, files, cache_control, reasoning effort, tool choice, structured output as a system instruction), and Claude's answers, streamed or whole, become Chat Completions chunks and completions. Claude logins stay Claude Code only.
Move each install's button out of the narrow table column into its own section, shown at 320 px wide, and bring the Workers-only description up to date.
Record each API request in the Durable Object, batched a few seconds apart: success and failure counts per login file and API key (totals and CPA's twenty 10-minute buckets) and, while logging to file is on, a CPA style request line (time, status, latency, client IP, path, provider, model; never bodies, keys or the query). The dashboard's credential list, API-key usage and Logs pages read them back. API keys are stored only as hashes.
Responses requests are translated to Anthropic Messages (ported from CPA's Responses-to-Claude translator) and sent to a Claude key, or on through the existing Claude translators to Gemini, OpenAI-compatible and Codex keys and the ChatGPT login. Answers come back as Responses events or a whole response. Chat clients take the same route to the providers they couldn't reach before.
…-y9ekd4 # Conflicts: # free/README.md
…-y9ekd4 # Conflicts: # free/src/app.ts
…-y9ekd4 # Conflicts: # free/src/app.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
OpenAI Responses clients (
/v1/responses) could only reach Codex keys and ChatGPT logins. Now they reach every provider, and so do OpenAI Chat clients, by pivoting through Anthropic Messages:free/src/responses-claude.ts(new), ported from CPA'stranslator/claude/openai/responses:instructionsand system/developer items become the system prompt;input_text/output_text/refusal/input_image/input_fileparts;reasoningitems replay as thinking only when they carry a Claude signature (OpenAI'sgAAAA…tokens are dropped);function_callandcustom_tool_callbecometool_use(custom tools take a one-string{input}schema); tool outputs keep the last result per call id; missing results are filled in as an "interrupted" error and orphaned ones become text, so Claude always gets valid pairing; a trailing thought is stripped;reasoning.effort,max_output_tokens,text.format,tool_choice(incl.allowed_tools, custom),parallel_tool_calls. Built-in tools (web search etc.) are dropped.ResponsesStreamturns Anthropic events into Responses SSE (response.created…output_item.added/done, text and reasoning-summary deltas, function-call argument deltas, custom tool input,response.completed/incomplete/failed, sequence numbers, usage with cached tokens).responsesResponsedoes the same for non-streaming clients.free/src/app.ts:viaClaudeKeybecomesviaClaudeMessages, used for Chat and Responses clients. It translates to Claude, then sends to a Claude key directly or through the existing Claude→Chat/Gemini/Responses translators (viaTranslationsplit so its core takes a parsed body), and converts back. Upstream errors come back in the client's error shape.servable()now lets Chat and Responses clients use every provider; Chat clients asking for a ChatGPT model also get the ChatGPT login. Gemini clients are unchanged (next PR).free/src/openai-claude.ts: helpers exported for reuse, no behaviour change.Security and safety
Tests
npm run verify: typecheck, lint and 170 tests pass. Newfree/test/responses-claude.test.tscovers request translation, streaming order and sequence numbers, custom tools, incomplete/failed streams and whole responses.app.test.tsadds Responses → Claude key (streamed and whole), Responses → OpenAI-compatible key, errors in the Responses shape, and Chat → ChatGPT login.Generated by Claude Code