Skip to content

Openrouter api support #14

Closed
Closed

Description

@Remilya

It would be awesome if we can use different api services.

Activity

  1. geogod42 commented on Apr 16, 2025

    @geogod42

    give me a hour

  2. DiegoSpinola commented on Apr 16, 2025

    @DiegoSpinola

    you can use the env var OPENAI_BASE_URL

  3. KorigamiK commented on Apr 16, 2025

    @KorigamiK

    you can use the env var OPENAI_BASE_URL

    This doesn't seem to work right now even if you set up the baseurl and model names correctly since the agent loop requests the chat completions using the new openai /v1/responses api instead of the older /v1/chat/completions api which other providers already support.

    This however seems to be a deliberate way to discourage using your own models to run codex and some work on this front would be very helpful for all.

  4. DiegoSpinola commented on Apr 16, 2025

    @DiegoSpinola

    So maybe adding something like this proxy to the mix:

    https://github.com/open-responses/open-responses

  5. codefromthecrypt commented on Apr 16, 2025

    @codefromthecrypt

    Should we keep this titled as OpenRouter API support, or /chat/completions instead? If the latter, it basically opens up a floodgate of options.

  6. DD1302 commented on Apr 17, 2025

    @DD1302

    Is anyone still working on this? Would love to use openrouter on codex

  7. Soren8 commented on Apr 18, 2025

    @Soren8

    Looks like there's a fork here https://github.com/ymichael/open-codex, but most discussion about this feature is in #26

  8. codex-maintainers commented on Aug 7, 2025

    @codex-maintainers

    Thank you for the feedback! Please try again on the latest version of Codex CLI. If the issue persists, let us know.

  9. timqian commented on Sep 8, 2025

    @timqian

    @codex-maintainers
    This feature does not work on the latest version of codex.

    > sudo npm i -g @openai/codex
    > codex --version
    codex-cli 0.30.0
    Image
  10. timqian commented on Sep 8, 2025

    @timqian

    Found the solution, looks like the way to use other models has been changed, one needs to refer to this doc to use other models(by using config.toml): https://github.com/openai/codex/blob/main/docs/config.md

    This is a working config.toml to use openrouter if anyone need

    model_provider="openrouter"
    model="openai/gpt-5"
    
    [model_providers.openrouter]
    name="openrouter"
    base_url="https://openrouter.ai/api/v1"
    env_key="OPENROUTER_API_KEY"
    
  11. added a commit that references this issue on Sep 8, 2025
    5b722e0
  12. chongdashu commented on Sep 10, 2025

    @chongdashu

    Found the solution, looks like the way to use other models has been changed, one needs to refer to this doc to use other models(by using config.toml): https://github.com/openai/codex/blob/main/docs/config.md

    This is a working config.toml to use openrouter if anyone need

    model_provider="openrouter"
    model="openai/gpt-5"
    
    [model_providers.openrouter]
    name="openrouter"
    base_url="https://openrouter.ai/api/v1"
    env_key="OPENROUTER_API_KEY"
    

    This still doesn't work for me. After setting above, you you run codex -model openrouter ?

  13. timqian commented on Sep 10, 2025

    @timqian

    Found the solution, looks like the way to use other models has been changed, one needs to refer to this doc to use other models(by using config.toml): https://github.com/openai/codex/blob/main/docs/config.md
    This is a working config.toml to use openrouter if anyone need

    model_provider="openrouter"
    model="openai/gpt-5"
    
    [model_providers.openrouter]
    name="openrouter"
    base_url="https://openrouter.ai/api/v1"
    env_key="OPENROUTER_API_KEY"
    

    This still doesn't work for me. After setting above, you you run codex -model openrouter ?

    after updating the config, just run codex works for me

    BTW, you will also need the OPENROUTER_API_KEY env in your .bashrc/ .zshrc

  14. added a commit that references this issue on Dec 4, 2025
  15. Galileo01 commented on Jun 3, 2026

    @Galileo01

    this config.toml ,It doesn't work for me,still need login

    Image codex-cli 0.136.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions