Skip to main content

CodeCortex AI โ€” autonomous coding agent for the terminal

Project description

๐Ÿง  CodeCortex AI

An autonomous AI coding agent that lives in your terminal.

CodeCortex AI reads your code, writes files, runs commands, fixes bugs, and builds features โ€” all from a simple chat interface.

PyPI version Python License: MIT


๐Ÿ“ฆ Installation

pip install codecortex-ai

That's it! Now you can use codecortex from anywhere in your terminal.


๐Ÿš€ Quick Setup (Step by Step)

When you run codecortex for the first time, it will ask you 3 things:

Step 1: Get an API Key

You need an API key from any AI provider. We recommend OpenRouter because it has free models:

  1. Go to openrouter.ai/keys
  2. Sign up / Log in (you can use Google)
  3. Click "Create Key"
  4. Copy the key (starts with sk-or-...)

๐Ÿ’ก Other providers also work: OpenAI (sk-proj-...), Anthropic, Groq, Together AI โ€” any OpenAI-compatible API.

โš ๏ธ Note: OpenAI requires billing credits ($5 minimum). OpenRouter has free models โ€” no payment needed.

Step 2: Run CodeCortex

codecortex

It will show you a setup wizard:

โ•ญโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ
โ”‚       Welcome to CodeCortex AI               โ”‚
โ”‚       First-time setup                       โ”‚
โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ

  Enter API Key: sk-or-v1-xxxxxxxxxxxx

  Enter Base URL (or press Enter to skip): https://openrouter.ai/api/v1

  Enter Model Name (or press Enter for default): mistralai/devstral-2512:free

  โœ… Configuration saved!

Step 3: What to Enter

Field What to Enter Example
API Key Your API key from the provider sk-or-v1-abc123...
Base URL The API endpoint URL https://openrouter.ai/api/v1
Model Name Which AI model to use mistralai/devstral-2512:free

๐Ÿ“‹ Setup Examples for Different Providers

๐ŸŸข OpenRouter (Recommended โ€” FREE models available)
API Key:    sk-or-v1-your-key-here
Base URL:   https://openrouter.ai/api/v1
Model:      mistralai/devstral-2512:free

Free models on OpenRouter:

Model Best For
mistralai/devstral-2512:free Coding tasks (recommended)
google/gemini-2.0-flash-exp:free General + coding
meta-llama/llama-4-maverick:free General purpose
qwen/qwen3-235b-a22b:free Coding + reasoning

Get your key: openrouter.ai/keys

๐Ÿ”ต OpenAI (Paid โ€” requires $5+ credits)
API Key:    sk-proj-your-key-here
Base URL:   (leave empty, press Enter)
Model:      gpt-4o-mini

Available models:

Model Cost
gpt-4o-mini Cheapest, great for most tasks
gpt-4o More powerful, costs more
gpt-3.5-turbo Budget option

โš ๏ธ You must add billing credits at platform.openai.com/settings/organization/billing

Get your key: platform.openai.com/api-keys

๐ŸŸก Groq (Free tier available)
API Key:    gsk_your-key-here
Base URL:   https://api.groq.com/openai/v1
Model:      llama-3.3-70b-versatile

Get your key: console.groq.com/keys

๐ŸŸ  Together AI
API Key:    your-key-here
Base URL:   https://api.together.xyz/v1
Model:      meta-llama/Meta-Llama-3.1-70B-Instruct-Turbo

Get your key: api.together.ai/settings/api-keys


๐Ÿ’ฌ Usage

Interactive Mode (chat with the agent)

codecortex

Then just type what you want:

> fix the bug in main.py
> add a login page to my app
> explain how this codebase works
> write unit tests for utils.py

Single Command Mode

codecortex "fix the type error in app.py"

Set Working Directory

codecortex --cwd ./my-project

๐Ÿ”ง All Commands

Terminal Commands

Command What It Does
codecortex Start interactive chat mode
codecortex "prompt" Run a single prompt and exit
codecortex --cwd ./path Set working directory
codecortex --reset Delete saved config and re-enter API key, model, etc.
codecortex --help Show help

Chat Commands (type inside CodeCortex)

Command What It Does
/help Show all available commands
/config Show current configuration (model, temperature, etc.)
/model <name> Change model (e.g., /model gpt-4o)
/approval <policy> Change approval policy (auto, on-request, never)
/tools List all available tools the agent can use
/mcp List connected MCP servers
/stats Show session statistics (turns, tokens used)
/save Save current session
/sessions List all saved sessions
/resume <id> Resume a saved session
/checkpoint Create a checkpoint (snapshot)
/restore <id> Restore from a checkpoint
/clear Clear conversation history
/exit Quit CodeCortex

โ“ Troubleshooting

"Wrong API key" / Want to change settings?

codecortex --reset

This deletes your saved config and asks for everything again.

"Model does not exist" error?

You entered a wrong model name. Common mistakes:

  • โŒ chatgpt โ†’ โœ… gpt-4o-mini
  • โŒ gpt4 โ†’ โœ… gpt-4o
  • โŒ claude โ†’ โœ… anthropic/claude-3.5-sonnet (on OpenRouter)

Fix it:

codecortex --reset

"No API key found" error?

Run setup again:

codecortex --reset

"Insufficient quota" / "billing" error?

Your OpenAI account has no credits. Either:

  1. Add $5 credits at platform.openai.com
  2. OR switch to OpenRouter (free): codecortex --reset

Where is my config saved?

Your configuration is saved at:

~/.codecortex/config.json

You can also manually edit this file.


๐Ÿ› ๏ธ What Can CodeCortex Do?

CodeCortex AI can autonomously:

  • ๐Ÿ“ Read & Write Files โ€” edit code, create new files, modify configs
  • ๐Ÿ–ฅ๏ธ Run Terminal Commands โ€” install packages, run tests, build projects
  • ๐Ÿ” Search Code โ€” find functions, grep patterns, understand codebase
  • ๐Ÿ› Fix Bugs โ€” analyze errors, debug issues, apply patches
  • ๐ŸŒ Web Search โ€” look up documentation, find solutions online
  • ๐Ÿ”Œ MCP Servers โ€” connect to external tools and services
  • ๐Ÿ’พ Session Management โ€” save, resume, and checkpoint conversations

๐Ÿค Contributing

GitHub: Tanishq-S-Dev05/CodeCortex-AI


๐Ÿ“„ License

MIT License โ€” use it however you want!

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

codecortex_ai-0.1.2.tar.gz (56.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

codecortex_ai-0.1.2-py3-none-any.whl (69.1 kB view details)

Uploaded Python 3

File details

Details for the file codecortex_ai-0.1.2.tar.gz.

File metadata

  • Download URL: codecortex_ai-0.1.2.tar.gz
  • Upload date:
  • Size: 56.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.7

File hashes

Hashes for codecortex_ai-0.1.2.tar.gz
Algorithm Hash digest
SHA256 de74162ffaeda360474ec807421585a429b87fc131aef31b1cbde5a8932d60ed
MD5 66953334b7ef4d7e62b289ecc8f7e263
BLAKE2b-256 21456cf05095bdb85c6ec624ade86efeb47f95677e402bcf52240e57702bad00

See more details on using hashes here.

File details

Details for the file codecortex_ai-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: codecortex_ai-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 69.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.7

File hashes

Hashes for codecortex_ai-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 a79569997f588bb457912354429a4e4549d2922cb55ebe0de101b18806d1b2ff
MD5 f853a7bdd3554a978c0c323cf9eb53c8
BLAKE2b-256 6e385e888c4f5cb3568f3f0a529ba87fd40c8fdb3b04e7e0ac96254bdfde01f2

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page