{"slug":"gpt-5.1-codex-mini","name":"GPT-5.1-Codex-Mini","family":"openai","family_name":"OpenAI","developer":"OpenAI","color":"#10a37f","status":"active","released":"2025-11-13","snapshot_of":null,"open":false,"context":400000,"max_output":128000,"knowledge_cutoff":"2024-09","modalities":["text","image"],"output_modalities":["text"],"reasoning":true,"tools":true,"structured_output":true,"huggingface":null,"speed":62,"latency":3.27,"short":"A closed-weight, low-cost coding model from OpenAI, released November 2025. It stands out on terminal tasks and falls behind on web app generation.","strengths":["61.6% on Terminal-Bench, 10th of 35, well above the 43.2% median","Input costs $0.25 per million tokens, with blended price below the median","400k context window and up to 128k output tokens","Accepts text and images, with tool calling and structured output"],"weaknesses":["WebDev Arena rating of 1247, 83rd of 85, below the 1506 median","Popularity ranks 177th of 194 in the registry","Only two benchmark results, so performance evidence is limited"],"best_for":"Terminal and command-running agents where low cost matters more than web app generation quality.","long":"GPT-5.1-Codex-Mini is a closed-weight model from OpenAI, released in November 2025. It has a 400k token context window, up to 128k tokens of output, and accepts text and images. It supports tool calling, reasoning and structured output. Its input price is low at $0.25 per million tokens, and its blended price of about $0.69 per million tokens sits below the registry median.\n\nIts clearest benchmark result is Terminal-Bench, where it completes 61.6% of tasks, placing 10th of 35 and well above the median of 43.2%. Its WebDev Arena rating of 1247 ranks 83rd of 85, far below the median of 1506, which points to weaker results on building web apps. Only two benchmark results are available, so the picture is limited.\n\nThe model is seldom chosen in the registry, ranking 177th of 194 for popularity. Its knowledge cutoff is September 2024. Developers should weigh these limits against its terminal performance and low input price when choosing it for agents that run commands.","described":true,"gateway":true,"byok":true,"string":"gateway/openai:gpt-5.1-codex-mini","input":0.25,"output":2,"cache_read":0.025,"blended":0.6875,"efficiency":null,"bench":{"terminal":61.6,"webdev":1247},"offers":[{"provider":"openai","name":"OpenAI","model_id":"gpt-5.1-codex-mini","api":["openai"],"input":0.25,"output":2,"cache_read":0.025,"cache_write":null,"input_tiers":[],"output_tiers":[],"context":400000,"deprecated":false,"gateway":true,"gateway_route":"openai","byok":true,"string":"openai:gpt-5.1-codex-mini","gateway_string":"gateway/openai:gpt-5.1-codex-mini"},{"provider":"openrouter","name":"OpenRouter","model_id":"openai/gpt-5.1-codex-mini","api":["openai"],"input":0.25,"output":2,"cache_read":0.03,"cache_write":null,"input_tiers":[],"output_tiers":[],"context":400000,"deprecated":false,"gateway":false,"gateway_route":null,"byok":true,"string":"openrouter:openai/gpt-5.1-codex-mini","gateway_string":null}],"ranks":{"intelligence":null,"popularity":177,"efficiency":null,"speed":103,"price":77},"top_score":0.031,"about":["A closed-weight, low-cost coding model from OpenAI, released November 2025. It stands out on terminal tasks and falls behind on web app generation.","GPT-5.1-Codex-Mini is a closed-weight model from OpenAI, released in November 2025. It has a 400k token context window, up to 128k tokens of output, and accepts text and images. It supports tool calling, reasoning and structured output. Its input price is low at $0.25 per million tokens, and its blended price of about $0.69 per million tokens sits below the registry median.","Its clearest benchmark result is Terminal-Bench, where it completes 61.6% of tasks, placing 10th of 35 and well above the median of 43.2%. Its WebDev Arena rating of 1247 ranks 83rd of 85, far below the median of 1506, which points to weaker results on building web apps. Only two benchmark results are available, so the picture is limited.","The model is seldom chosen in the registry, ranking 177th of 194 for popularity. Its knowledge cutoff is September 2024. Developers should weigh these limits against its terminal performance and low input price when choosing it for agents that run commands."],"examples":[{"file":"hello.py","lang":"python","code":"# /// script\n# dependencies = [\"pydantic-ai\"]\n# ///\nimport os\n\nfrom pydantic_ai import Agent\n\nos.environ['PYDANTIC_AI_GATEWAY_API_KEY'] = '...'\n\nagent = Agent('gateway/openai:gpt-5.1-codex-mini', instructions='Be concise, reply with one sentence.')\n\nresult = agent.run_sync('Where does \"hello world\" come from?')\nprint(result.output)","soon":false},{"file":"structured_output.py","lang":"python","code":"# /// script\n# dependencies = [\"pydantic-ai\"]\n# ///\nimport os\n\nfrom pydantic import BaseModel\nfrom pydantic_ai import Agent\n\nos.environ['PYDANTIC_AI_GATEWAY_API_KEY'] = '...'\n\n\nclass CityLocation(BaseModel):\n    city: str\n    country: str\n\n\nagent = Agent('gateway/openai:gpt-5.1-codex-mini', output_type=CityLocation)\n\nresult = agent.run_sync('Where were the olympics held in 2012?')\nprint(result.output)\n#> city='London' country='United Kingdom'","soon":false},{"file":"tools.py","lang":"python","code":"# /// script\n# dependencies = [\"pydantic-ai\"]\n# ///\nimport os\nimport random\n\nfrom pydantic_ai import Agent, RunContext\n\nos.environ['PYDANTIC_AI_GATEWAY_API_KEY'] = '...'\n\nagent = Agent(\n    'gateway/openai:gpt-5.1-codex-mini',\n    deps_type=str,\n    instructions=\"You're a dice game, roll the die and see if it matches the user's guess.\",\n)\n\n\n@agent.tool_plain\ndef roll_dice() -> str:\n    \"\"\"Roll a six-sided die and return the result.\"\"\"\n    return str(random.randint(1, 6))\n\n\n@agent.tool\ndef get_player_name(ctx: RunContext[str]) -> str:\n    \"\"\"Get the player's name.\"\"\"\n    return ctx.deps\n\n\nresult = agent.run_sync('My guess is 4', deps='Anne')\nprint(result.output)","soon":false},{"file":"streaming.py","lang":"python","code":"# /// script\n# dependencies = [\"pydantic-ai\"]\n# ///\nimport asyncio\nimport os\n\nfrom pydantic_ai import Agent\n\nos.environ['PYDANTIC_AI_GATEWAY_API_KEY'] = '...'\n\nagent = Agent('gateway/openai:gpt-5.1-codex-mini')\n\n\nasync def main():\n    async with agent.run_stream('Explain prompt caching in three bullet points.') as response:\n        async for text in response.stream_text(delta=True):\n            print(text, end='', flush=True)\n\n\nasyncio.run(main())","soon":false},{"file":"pax.sh","lang":"sh","code":"export PYDANTIC_AI_GATEWAY_API_KEY='...'\n\nuvx pax --model 'gateway/openai:gpt-5.1-codex-mini'","soon":true},{"file":"pi.sh","lang":"sh","code":"# npm install -g @earendil-works/pi-coding-agent\nexport PYDANTIC_AI_GATEWAY_API_KEY='...'\n\n# pi has no built-in Gateway provider, so register one.\n# Merge this by hand if you already have a models.json.\nmkdir -p ~/.pi/agent\ncat > ~/.pi/agent/models.json <<'EOF'\n{\n  \"providers\": {\n    \"pydantic-ai-gateway\": {\n      \"baseUrl\": \"https://gateway.pydantic.dev/proxy/openai/v1\",\n      \"api\": \"openai-responses\",\n      \"apiKey\": \"$PYDANTIC_AI_GATEWAY_API_KEY\",\n      \"models\": [\n        {\n          \"id\": \"gpt-5.1-codex-mini\"\n        }\n      ]\n    }\n  }\n}\nEOF\n\npi --provider pydantic-ai-gateway --model 'gpt-5.1-codex-mini'","soon":false},{"file":"codex.sh","lang":"sh","code":"# npm install -g @openai/codex\nexport PYDANTIC_AI_GATEWAY_API_KEY='...'\n\ncodex --model 'gpt-5.1-codex-mini' \\\n  -c model_provider='gateway' \\\n  -c model_providers.gateway.name='Pydantic AI Gateway' \\\n  -c model_providers.gateway.base_url='https://gateway.pydantic.dev/proxy/openai/v1' \\\n  -c model_providers.gateway.env_key='PYDANTIC_AI_GATEWAY_API_KEY'","soon":false},{"file":"ai_sdk.ts","lang":"ts","code":"// npm install ai @ai-sdk/openai\nimport { createOpenAI } from '@ai-sdk/openai'\nimport { generateText } from 'ai'\n\nprocess.env.PYDANTIC_AI_GATEWAY_API_KEY = '...'\n\nconst openai = createOpenAI({\n  baseURL: 'https://gateway.pydantic.dev/proxy/openai',\n  apiKey: process.env.PYDANTIC_AI_GATEWAY_API_KEY,\n})\n\nconst { text } = await generateText({\n  model: openai('gpt-5.1-codex-mini'),\n  system: 'Be concise, reply with one sentence.',\n  prompt: 'Where does \"hello world\" come from?',\n})\nconsole.log(text)","soon":false}],"benchmarks":[{"id":"terminal","name":"Terminal-Bench","unit":"%","desc":"Tasks completed in a terminal; the best result of any agent using the model","category":"coding","floor":0,"ceiling":100,"url":"https://www.tbench.ai/leaderboard/terminal-bench/2.0","credit":"Terminal-Bench, via Epoch AI (CC BY 4.0)"},{"id":"webdev","name":"WebDev Arena","unit":"","desc":"Rating from human votes on web apps the models built","category":"coding","floor":1000,"ceiling":1900,"url":"https://web.lmarena.ai/leaderboard","credit":"LMArena, via Epoch AI (CC BY 4.0)"}],"generated":"2026-11-25","gaps":{"speed":3,"index":80,"description":0}}