Add OpenAI-compatible API provider support#905
Draft
taneron wants to merge 1 commit intoanthropics:mainfrom
Draft
Add OpenAI-compatible API provider support#905taneron wants to merge 1 commit intoanthropics:mainfrom
taneron wants to merge 1 commit intoanthropics:mainfrom
Conversation
Add support for any OpenAI-compatible API (OpenRouter, z.ai, Together, Groq, etc.) as an alternative to the Claude Code SDK. This enables the action to work with any model that exposes an OpenAI-style /chat/completions endpoint. New action inputs: - use_openai_compatible: enable OpenAI-compatible mode - openai_compatible_api_key: API key (store in GitHub Secrets) - openai_compatible_base_url: API base URL - openai_compatible_model: model name (e.g., glm-4.7) - openai_compatible_max_tokens: max response tokens (default 4096) Also forward ANTHROPIC_AUTH_TOKEN and ANTHROPIC_MODEL env vars for the existing OpenRouter-via-Claude-Code approach. https://claude.ai/code/session_013nXy9KcNS5Ag8uajpLgPLo
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.
Summary
This PR adds support for OpenAI-compatible API providers (e.g., OpenRouter, z.ai, Together, Groq) as an alternative to the Claude Code SDK. Users can now route prompts through any API that implements the OpenAI chat completions specification.
Key Changes
New Action Inputs: Added four new workflow inputs to configure OpenAI-compatible providers:
use_openai_compatible: Enable/disable the featureopenai_compatible_api_key: API key for the provideropenai_compatible_base_url: Base URL of the API endpointopenai_compatible_model: Model name to useopenai_compatible_max_tokens: Maximum response tokens (default: 4096)New Module (
run-openai-compatible.ts): Implements the alternative execution path that:Routing Logic (
run-claude.ts): Added provider detection and routing:isOpenAICompatibleMode(): Checks if OpenAI-compatible mode is enabledgetOpenAICompatibleConfig(): Builds config from environment variablesEnvironment Validation (
validate-env.ts): Enhanced to:Execution Flow (
run.ts): Optimized to:Comprehensive Tests (
run-openai-compatible.test.ts): Added 8 test cases covering:Implementation Details
/v1,/v4, or already containing/chat/completionsshow_full_output: true)Testing
All new functionality is covered by unit tests with mocked fetch calls. Existing tests updated to account for the new provider option.
https://claude.ai/code/session_013nXy9KcNS5Ag8uajpLgPLo