Skip to content

[BUG] BYOK custom models with gpt-5.2* names route to Fireworks instead of configured OpenAI provider #611

@mikez93

Description

@mikez93

Summary

Custom models with names matching gpt-5.2* pattern ignore provider: "openai" and baseUrl: "https://api.openai.com/v1" settings, routing to Fireworks instead. This prevents using BYOK (Bring Your Own Key) with GPT-5.2 models.

Factory Version

0.53.0

Steps to Reproduce

  1. Add a custom model to ~/.factory/settings.json:
{
  "customModels": [
    {
      "model": "gpt-5.2",
      "id": "custom:GPT-52-Test",
      "baseUrl": "https://api.openai.com/v1",
      "apiKey": "sk-...",
      "provider": "openai"
    }
  ]
}
  1. Run: droid exec --model "custom:GPT-52-Test" "say OK"

  2. Check logs at ~/Library/Logs/factoryd/factoryd.log

Expected Behavior

Request should be sent to https://api.openai.com/v1 using the configured API key and provider: "openai".

Actual Behavior

Request fails with 400 error. Logs show:

"apiProvider": "fireworks"

Despite explicitly setting provider: "openai", Factory routes the request to Fireworks.

Evidence

Control test with GPT-4o (same config pattern):

{
  "model": "gpt-4o",
  "id": "custom:GPT-4o-Test",
  "baseUrl": "https://api.openai.com/v1",
  "apiKey": "sk-...",
  "provider": "openai"
}

Result: Works correctly - routes to OpenAI.

The only difference is the model name. Models matching gpt-5.2* have their provider settings overridden.

Additional Context

This appears related to the v0.53.0 native GPT-5.2 Codex support. The model name pattern detection seems to override custom model BYOK settings even when a custom baseUrl and provider are explicitly configured.

Verified the OpenAI API key works directly via curl:

curl https://api.openai.com/v1/chat/completions \
  -H "Authorization: Bearer $OPENAI_API_KEY" \
  -d '{"model": "gpt-5.2", "messages": [{"role": "user", "content": "say OK"}], "max_completion_tokens": 10}'
# Returns valid response

Suggested Fix

Custom models with explicit baseUrl and provider settings should respect those settings regardless of model name pattern matching. The native Codex integration should only apply when no custom configuration is present.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions