Skip to content

Support custom base URL for OpenAI Responses API#342

Open
chyax98 wants to merge 1 commit into
1jehuang:masterfrom
chyax98:feature/openai-responses-custom-base
Open

Support custom base URL for OpenAI Responses API#342
chyax98 wants to merge 1 commit into
1jehuang:masterfrom
chyax98:feature/openai-responses-custom-base

Conversation

@chyax98

@chyax98 chyax98 commented Jun 8, 2026

Copy link
Copy Markdown

Closes #343

Problem

The native openai-api provider uses the OpenAI Responses API, but its base URL was hardcoded to https://api.openai.com/v1. Users with a local or proxied Responses API endpoint could only configure openai-compatible, which is the wrong protocol path because it targets OpenAI-compatible chat/completions rather than native /responses.

Summary

  • Allow native openai-api Responses API requests to use a custom API base URL.
  • Read the custom base URL from JCODE_OPENAI_API_BASE, OPENAI_API_BASE, or OPENAI_BASE_URL, including values saved in openai.env.
  • Support non-interactive setup via:
jcode login openai-api \
  --api-base http://127.0.0.1:8317/v1 \
  --api-key '<key>' \
  --model gpt-5.5
  • Keep openai-compatible separate and unchanged.
  • Keep ChatGPT/OAuth mode on the existing ChatGPT backend URL.

Edge cases and tradeoffs

  • The custom base URL only affects non-ChatGPT native OpenAI API-key mode. ChatGPT OAuth/subscription mode still uses https://chatgpt.com/backend-api/codex.
  • URL validation reuses the existing normalize_api_base policy, so HTTPS is accepted and private/local HTTP endpoints are allowed, while unsafe public HTTP endpoints are rejected.
  • Env precedence is JCODE_OPENAI_API_BASE, then OPENAI_API_BASE, then OPENAI_BASE_URL.

Validation

  • cargo check -p jcode-base -p jcode --bin jcode
  • Built local debug binary and verified native openai-api against a local Responses endpoint:
/Users/xd/.jcode/source/jcode/target/debug/jcode \
  --socket /tmp/jcode-openai-base-test.sock \
  -p openai-api -m gpt-5.5 \
  run 'Reply exactly JCODE_RESPONSES_BASE_OK'

Result:

JCODE_RESPONSES_BASE_OK

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow native OpenAI Responses API to use custom base URL

2 participants