Skip to content

Support for local / other LLMs #26

Closed

Description

@imggion

Image

I’d love to be able to use Codex locally, for example to ask it questions about my system, my server, and everything I have on my computer, without necessarily having to go through your servers.

That would be really cool and would give everyone the opportunity to have full control over their own data.

Activity

  1. tibo-openai commented on Apr 16, 2025

    @tibo-openai
    Collaborator

    The current logic supports the openai sdk, but we are excited to review contributions that would decouple this if done without introducing significant complexity to the project.

    Some parts about the code patch format that the model is expected to generate are quite specific to the openai models as we have seen this improve general accuracy and model performance, and so at the moment this isn't a trivial refactor and change.

  2. imggion commented on Apr 16, 2025

    @imggion
    Author

    @tibo-openai I’d be very happy to find a way to introduce this without making the project too complex.

  3. nannan-motorq commented on Apr 16, 2025

    @nannan-motorq

    Will there be support for Azure OpenAI? I don’t see an option to set a custom endpoint. This would be a great addition for enterprise use

  4. Pl8tinium commented on Apr 16, 2025

    @Pl8tinium

    i knew this would be the very first question people will be asking 😁

  5. KorigamiK commented on Apr 16, 2025

    @KorigamiK

    There doesn't seem to be any as far as I can see

    #14 (comment)

  6. added
    enhancement
    on Apr 16, 2025
  7. changed the title [-]Required API Key - Is there any way to use it with a local LLM?[/-] [+]Using with local LLM?[/+] on Apr 16, 2025
  8. vmotta8 commented on Apr 17, 2025

    @vmotta8
    Contributor

    This project is currently using the /responses endpoint from OpenAI's API. Ollama has compatibility with some OpenAI API endpoints, but the /responses endpoint is not included yet. If Ollama supported this endpoint, we could simply update the OPENAI_BASE_URL variable (defined here) to point directly to the Ollama URL.

    I've opened an issue in the Ollama repository about this

  9. rjxby commented on Apr 17, 2025

    @rjxby

    Hi all,

    Would the maintainers be open to adding a lightweight LLMProvider abstraction in the CLI? The idea is to decouple transport from prompt/patch logic, so you could plug in OpenAI, Ollama (or any other backend).

    E.g., an interface:

    interface LLMProvider {
    complete(prompt: string, opts: any): Promise;
    }

    and two simple adapters (OpenAIProvider for /responses, OllamaProvider for /completions + wrap). Defaults remain on OpenAI.

    This keeps the CLI flexible for local/offline models while preserving existing behavior. Curious if this aligns with the repo’s roadmap - thanks!

  10. SawyerHood commented on Apr 17, 2025

    @SawyerHood

    I just found this fork which uses the completions api to work with gemini! It could probably work with ollama as well https://github.com/ymichael/codex

  11. marty-sullivan commented on Apr 17, 2025

    @marty-sullivan

    The best current way to do this is to use LiteLLM Proxy. You can quickly spin one up locally.

    https://docs.litellm.ai/docs/simple_proxy

    All you have to do is set OPENAI_BASE_URL to your local LiteLLM proxy and then you can set OPENAI_API_KEY to your LiteLLM proxy key.

    Voila, you can configure any model you want from any provider that supports Responses API (currently only directly to OpenAI, but should be available for other providers soon) and codex works!

  12. DuinoDu commented on Apr 17, 2025

    @DuinoDu
  13. tcztzy commented on Apr 17, 2025

    @tcztzy
  14. marty-sullivan commented on Apr 17, 2025

    @marty-sullivan

    @tcztzy They have implemented Responses API already, it is just not supported for all providers yet. They are adding Azure support this week:

    BerriAI/litellm#9653 (comment)

    Appreciate the downvote though.

  15. mrmartin commented on Apr 17, 2025

    @mrmartin

    https://github.com/mudler/LocalAI lets you host local LLMs with /v1/responses
    Can't wait to try it out!

  16. 29 remaining items

  17. MSDimos commented on Apr 21, 2025

    @MSDimos

    It seesm like codex has supported DeepSeek already?

    It works for me like below:

    codex -p deepseek

    I didn't set OPENAI_API_KEY, on the contrary, I set DEEPSEEK_API_KEY, and it indeed works properly.

    Image
  18. nb0309 commented on Apr 21, 2025

    @nb0309

    @MSDimos how did you change the model name for the codex, I have set the api for DEEPSEEK_API_KEY yet the model hasn't changed

    Image

  19. MSDimos commented on Apr 21, 2025

    @MSDimos

    @nb0309

    codex -m deepseek-chat -p deepseek

    If it doesn't work, try to update to the latest version. There is still a lot of work for improvement in the code support for deepseek.

  20. Cachet23 commented on Apr 25, 2025

    @Cachet23

    Hey everyone, I am currently trying to use a self hosted deepseek model within codex, so I have set myself up with a devcontainer containing everything i need (node, npm, litellm, openai, ... ). If this issue is to litellm related for this thread I am sorry.

    i have configured litellm like that:

    model_list:
      - model_name: deepseek-70b
        litellm_params:
          provider: openai
          model: openai/deepseek-ai/DeepSeek-R1-Distill-Llama-70B
          api_base: https://our_inference_ip:30000/v1    
          api_key: os.environ/OPENAI_API_KEY
    
    litellm_settings:
      ssl_verify: "/etc/ssl/certs/ca-certificates.crt"
      drop_params: true
    
    
    

    in devcontainer.json:

      "containerEnv": {
        "OPENAI_BASE_URL": "http://0.0.0.0:4000",
        "OPENAI_API_KEY": "sk-test"
      }
    
    

    our model can only be reached with a certificate. I have added the cert file within the container, so that it is possible for me to curl for a response from litellm like this:

    curl -v -H "Authorization: Bearer sk-test" -H "Content-Type: application/json" -d '{"model":"deepseek-70b","messages":[{"role":"user","content":"2+2"}]}' http://localhost:4000/v1/chat/completions

    I am able to receive answers form this endpoint. Here comes the codex related problem:
    remember the base_url and api_key are already set. I run the following command:
    codex --provider openai --model deepseek-70b -q "what is 2+2?"

    i receive:

    codex --provider openai --model deepseek-70b -q "what is 2+2?" {"role":"user","content":[{"type":"input_text","text":"what is 2+2?"}],"type":"message"} {"id":"error-1745578428541","type":"message","role":"system","content":[{"type":"input_text","text":"⚠️ OpenAI rejected the request. Error details: Status: 404, Code: 404, Type: unknown, Message: 404 litellm.NotFoundError: NotFoundError: OpenAIException - {\"detail\":\"Not Found\"}. Please verify your settings and try again."}]}

    on my litellm side of things i receive this error:
    httpx.HTTPStatusError: Client error '404 Not Found' for url 'https://10.244.192.53:30000/v1/responses' For more information check: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/404
    litellm.llms.base_llm.chat.transformation.BaseLLMException: {"detail":"Not Found"}
    litellm.exceptions.NotFoundError: litellm.NotFoundError: NotFoundError: OpenAIException - {"detail":"Not Found"}

    the question is "why is codex looking for /responses endpoint?" can i somehow provide that?

  21. gyasis commented on May 2, 2025

    @gyasis

    looks like litellm would have to allow for the new /responses endpoint. We may have to wait for an update or fix it ourselves....In the meantime, I'll look at the endpoint call functions and see how difficult that would be to add another endpoint

  22. theycallmeloki commented on May 2, 2025

    @theycallmeloki

    There is experimental support for /responses endpoint in a litellm release on this issue

    There is also discussion pertaining to responses api in the vllm issue here

    I would like pointers on how I can retroactively patch either or both layers to support codex, in the event this proves counterintuitive and the recommended way forward is to try and use /v1/responses I am very hesitant that effort spent there is basically useless because even if support lands in vllm I don't think it'll be trivial to finetune any B parameter models to work easily with /v1/responses because I am naively suspecting that the interfaces would have to be trained significantly by some big player with GPUs before it becomes effective again accross open source's definition of "open ai compatible api endpoint" (this is probably very naive, and potentially wrong, maybe vllm internally does all the logit stuff at a more granular level and the differences in /v1/responses and /v1/chat/completions is only cosmetic and purely app layer)

    I am very interested and keen on seeing this through and would like any pointers to get me started on the right angle of approach

  23. dnakov commented on May 2, 2025

    @dnakov
    Contributor

    Here's the set up for custom/local providers you need that support the (regular) OpenAI Completion API (not responses):

    1. Define your provider in ~/.codex/config.json
    2. export the provider_API_KEY env
    3. Change the OPENAI_BASE_URL env
    Image Image
  24. OriNachum commented on May 14, 2025

    @OriNachum

    @dnakov how is state managed?
    (And what about responses features, like web search, and upcoming MCP support?)

  25. dnakov commented on May 14, 2025

    @dnakov
    Contributor

    @dnakov how is state managed? (And what about responses features, like web search, and upcoming MCP support?)

    Just a pretty basic map:
    https://github.com/openai/codex/blob/main/codex-cli/src/utils/responses.ts#L165

    (And what about responses features, like web search, and upcoming MCP support?)

    I haven't tried web search, but it should work as its just defined as a tool call

  26. OriNachum commented on May 14, 2025

    @OriNachum

    It's worth noting that I wrote a middleware with state management. (So you work with responses and it operates any Chat Completions AI Provider)

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

    I'm about to finish adding MCPs support.

  27. fscfede-beep commented on Sep 19, 2026

    @fscfede-beep

    Final reconciliation update for the current patch series:

    Latest commit: 599fe2f861aed2041a62bacfa0dde2786799a689
    Compare vs isolated upstream baseline: 9 ahead / 0 behind.

    The latest commit fixes a compile-level omission found during self-audit by adding the TUI guard's missing ActivePermissionProfile and :danger-full-access imports.

    Evidence report:
    SHA-256 d1a3a5829d79264ff4a162c45eedfe8c41742c1069637b00cb74664365836ab6

    Current validation: static source/diff audit PASS; native Windows runtime NOT_PROVEN; no GitHub Actions run was visible yet for the exact latest commit.

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

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions