"OpenAI rejected the request." when working with an OLLAMA Server

Resolved 💬 5 comments Opened May 28, 2025 by AndreyBulezyuk Closed Oct 16, 2025

What version of Codex is running?

0.1.2505172129

Which model were you using?

llama3.1:latest

What platform is your computer?

Mac M3

What steps can reproduce the bug?

  1. Setup an OLLAMA Server (remote on linux) with llama3.1:latest installed and running
  2. Set following environment variables:
OPENAI_API_KEY=sk-none
OLLAMA_API_KEY=sk-none
OLLAMA_BASE_URL=http://<my-ollama-server-domain>:11434
OPENAI_API_BASE=http://<my-ollama-server-domain>:11434
OPENAI_BASE_URL=http://<my-ollama-server-domain>:11434
OPENAI_API_TYPE=ollama
  1. Verify that OLLAMA Server runs and works with
curl -X POST http://<my-ollama-server-domain>:11434/api/generate \
  -H "Content-Type: application/json" \
  -d '{
    "model": "llama3.1",
    "prompt": "Write a Python function to check if a number is prime.",
    "stream": false
  }'
  1. Execute codex on local machine (MAC M3), in the hope that it will use the Remotely OLLAMA-hosted llama3.1:latest model: codex -p ollama -m llama3.1:latest "fix mypy"

What is the expected behavior?

Start using the llama3.1 on the ollama remote server, as it would using openai models.

What do you see instead?

codex -p ollama -m llama3.1:latest "fix mypy"
╭──────────────────────────────────────────────────────────────╮
│ ● OpenAI Codex (research preview) v0.1.2505172129            │
╰──────────────────────────────────────────────────────────────╯
╭──────────────────────────────────────────────────────────────╮
│ localhost session: 2297e4d333d448dd9faf53ad2538b8a7          │
│ ↳ workdir: ~/n13/backend                                     │
│ ↳ model: llama3.1:latest                                     │
│ ↳ provider: ollama                                           │
│ ↳ approval: suggest                                          │
╰──────────────────────────────────────────────────────────────╯
user
fix mypy

    system
    ⚠️  OpenAI rejected the request. Error details: Status: 404, Code: unknown, Type: unknown, Message: 404 404 page not found. Please verify your settings and try again.

Additional information

When removing all OLLAMA_BASE_URL and other ENV vars, and using local OLLAMA with same llama3.1 model, kind of works a few times, before not recognizing some commands that llama3.1 wants to execute.

Either way, local or remote ollama, there integration of open source models is buggy and unusable for now (or docs are lacking on how to setup).

Remote OLLAMA models list:

{"models":[{"name":"llama3.1:latest","model":"llama3.1:latest","modified_at":"2025-05-28T14:40:42.648892115Z","size":4920753328,"digest":"46e0c10c039e019119339687c3c1757cc81b9da49709a3b3924863ba87ca666e","details":{"parent_model":"","format":"gguf","family":"llama","families":["llama"],"parameter_size":"8.0B","quantization_level":"Q4_K_M"}},{"name":"codellama:latest","model":"codellama:latest","modified_at":"2025-05-28T13:19:17.10603508Z","size":3825910662,"digest":"8fdf8f752f6e80de33e82f381aba784c025982752cd1ae9377add66449d2225f","details":{"parent_model":"","format":"gguf","family":"llama","families":null,"parameter_size":"7B","quantization_level":"Q4_0"}},{"name":"devstral:latest","model":"devstral:latest","modified_at":"2025-05-28T13:09:23.908710111Z","size":14333927918,"digest":"c4b2fa0c33d75457e5f1c8507c906a79e73285768686db13b9cbac0c7ee3a854","details":{"parent_model":"","format":"gguf","family":"llama","families":["llama"],"parameter_size":"23.6B","quantization_level":"Q4_K_M"}},{"name":"llama2:latest","model":"llama2:latest","modified_at":"2025-05-28T11:42:12.78598796Z","size":3826793677,"digest":"78e26419b4469263f75331927a00a0284ef6544c1975b826b15abdaef17bb962","details":{"parent_model":"","format":"gguf","family":"llama","families":["llama"],"parameter_size":"7B","quantization_level":"Q4_0"}}]}

View original on GitHub ↗

This issue has 5 comments on GitHub. Read the full discussion on GitHub ↗