Forge supports CodeGen's agent-based code generation API as a backend for building projects.
Sign up at codegen.com and get:
- API Token: From your account settings
- Organization ID: From your organization dashboard
export CODEGEN_API_KEY="your-api-key-here"
export CODEGEN_ORG_ID="your-org-id-here"Or add to your .env file:
CODEGEN_API_KEY=your-api-key-here
CODEGEN_ORG_ID=your-org-id-hereCreate or update forge.yaml:
generator:
backend: codegen_api
api_key: ${CODEGEN_API_KEY}
org_id: ${CODEGEN_ORG_ID}
timeout: 600 # 10 minutesOr use the global config at ~/.forge/config.yaml:
generator:
backend: codegen_api
api_key: ${CODEGEN_API_KEY}
org_id: ${CODEGEN_ORG_ID}# Plan your project
forge chat
# Build with CodeGen
forge build --project your-project-idForge will automatically:
- Create CodeGen agent runs for each task
- Poll for completion
- Extract generated files
- Write them to your project directory
CodeGen uses autonomous agents that:
- Understand project context
- Write production-ready code
- Follow best practices
- Generate tests automatically
- Handle dependencies correctly
Forge leverages CodeGen's parallel execution:
- Independent tasks run simultaneously
- Up to 10 concurrent agent runs (respecting rate limits)
- Faster overall project generation
Forge enriches CodeGen prompts with:
- Relevant patterns from the pattern library
- Project context and tech stack
- Dependency information
- File structure expectations
This ensures CodeGen generates code that follows best practices and integrates seamlessly.
# Initialize project
forge init my-api
# Start planning conversation
forge chat
> What would you like to build?
A REST API for task management with authentication
> What tech stack?
FastAPI, PostgreSQL, SQLAlchemy, JWT
> Any specific requirements?
- CRUD operations for tasks
- User authentication
- Task filtering by status
- Due date reminders
# (conversation continues...)
done
# Build with CodeGen
forge build --project my-api-20251207
# Output:
# ⚒ Forge Build System
#
# Project: Task Management API
# Stage: planning
#
# Found 12 tasks to build
# Backend: codegen_api
#
# Creating CodeGen agent runs...
# [1/12] Generating database models... ✓
# [2/12] Generating API endpoints... ✓
# ...
# [12/12] Generating tests... ✓
#
# ✓ Build completed in 8m 42s
# ✓ Generated 28 filesIf you're using a self-hosted CodeGen instance:
generator:
backend: codegen_api
api_key: ${CODEGEN_API_KEY}
org_id: ${CODEGEN_ORG_ID}
base_url: https://your-codegen-instance.com/v1Adjust timeout for complex tasks:
generator:
backend: codegen_api
api_key: ${CODEGEN_API_KEY}
org_id: ${CODEGEN_ORG_ID}
timeout: 900 # 15 minutes for complex tasksIf your project is already in a CodeGen-connected repository:
generator:
backend: codegen_api
api_key: ${CODEGEN_API_KEY}
org_id: ${CODEGEN_ORG_ID}
repository_id: "your-repo-id" # Optional: provides additional contextCodeGen API has rate limits:
- Agent creation: 10 requests per minute
- Status checks: 60 requests per 30 seconds
Forge automatically:
- Respects rate limits
- Implements exponential backoff
- Retries failed requests
Make sure CODEGEN_API_KEY is set:
echo $CODEGEN_API_KEY
# Should output your API key
# If not set:
export CODEGEN_API_KEY="your-key"Set CODEGEN_ORG_ID:
export CODEGEN_ORG_ID="your-org-id"Forge will automatically retry with exponential backoff. If you consistently hit limits:
- Reduce
max_parallelin config - Increase timeouts
- Contact CodeGen support for higher limits
Check the CodeGen dashboard at codegen.com to:
- View agent run details
- See error messages
- Review generated code
- Resume failed runs
CodeGen's response format may vary. If Forge isn't extracting files correctly:
- Check
.forge/logs/for detailed output - Manually review the CodeGen agent run
- Report the issue on GitHub
| Feature | CodeGen API | Claude Code |
|---|---|---|
| Execution | Cloud-based agents | Local CLI tool |
| Parallel tasks | Yes (10/min) | Yes (limited by machine) |
| Cost | Pay per agent run | API costs only |
| Setup | API key only | CLI installation |
| Web dashboard | Yes | No |
| Offline | No | Yes (with local model) |
- Start small: Test with 2-3 tasks before full project
- Review output: Check CodeGen dashboard for quality
- Iterate: Use
forge iterateto refine generated code - Save sessions: CodeGen keeps history in dashboard
- Monitor costs: Track agent runs to manage expenses
Questions? Open an issue on GitHub