### Install npm Dependencies Source: https://docs.codegen.com/sandboxes/setup-commands This command installs all the dependencies required for an npm project. Ensure Node.js and npm are available in the environment. ```bash npm install ``` -------------------------------- ### Configure Python Version with Pyenv Source: https://docs.codegen.com/sandboxes/setup-commands This example shows how to install a specific Python version (3.12.0) using pyenv, set it as the local version for the current directory, and then install project dependencies. ```bash # Install Python 3.12 (or your desired version) pyenv install 3.12.0 # Set Python 3.12 as the local version for your project pyenv local 3.12.0 # Create a virtual environment with Python 3.12 python -m venv venv source venv/bin/activate # Install your dependencies pip install -r requirements.txt ``` -------------------------------- ### Setup Python Environment with Pyenv Source: https://docs.codegen.com/sandboxes/setup-commands This script demonstrates how to install and configure pyenv to manage multiple Python versions. It installs Python 3.12, sets it as the local version for the project, creates a virtual environment, activates it, and installs dependencies using pip. ```bash # Install pyenv curl https://pyenv.run | bash # Add pyenv to PATH (for current session) export PATH="$HOME/.pyenv/bin:$PATH" eval "$(pyenv init -)" eval "$(pyenv virtualenv-init -)" # Install Python 3.12 (or your desired version) pyenv install 3.12.0 # Set Python 3.12 as the local version for your project pyenv local 3.12.0 # Create a virtual environment with Python 3.12 python -m venv venv source venv/bin/activate # Install your dependencies pip install -r requirements.txt ``` -------------------------------- ### Install npm Dependencies and Build Project Source: https://docs.codegen.com/sandboxes/setup-commands This sequence of commands first switches to a specific Node.js version (18), then installs project dependencies using `npm ci` for faster, cleaner installs, and finally runs the project's build script. ```bash # Switch to Node.js version 18 nvm use 18 npm ci npm run build ``` -------------------------------- ### Install Python Dependencies with Pip Source: https://docs.codegen.com/sandboxes/setup-commands This sequence of commands sets up a Python environment by installing a specific version using pyenv, creating a virtual environment, activating it, and then installing project dependencies from a requirements file. ```bash # Switch to Node.js version 20 nvm use 20 # Install npm dependencies npm install ``` -------------------------------- ### POST /v1/organizations/{org_id}/setup-commands/generate Source: https://docs.codegen.com/api-reference/setup-commands/generate-setup-commands Generates setup commands for a specified repository. This endpoint initiates an agent that analyzes the repository structure to create relevant setup commands. ```APIDOC ## POST /v1/organizations/{org_id}/setup-commands/generate ### Description Generates setup commands for a specified repository. This endpoint initiates an agent that analyzes the repository structure to create relevant setup commands. ### Method POST ### Endpoint https://api.codegen.com/v1/organizations/{org_id}/setup-commands/generate ### Parameters #### Path Parameters - **org_id** (integer) - Required - The ID of the organization. #### Query Parameters None #### Header Parameters - **authorization** (any) - Optional - Authorization token. #### Request Body - **repo_id** (integer) - Required - The ID of the repository. - **prompt** (string | null) - Optional - A prompt to guide the command generation. - **trigger_source** (string) - Optional - The source triggering the command generation (defaults to 'setup-commands'). ### Request Example ```json { "repo_id": 123, "prompt": "", "trigger_source": "setup-commands" } ``` ### Response #### Success Response (200) - **agent_run_id** (integer) - The ID of the agent run. - **status** (string) - The status of the setup command generation. - **url** (string) - A URL related to the setup command generation process. #### Response Example ```json { "agent_run_id": 123, "status": "", "url": "" } ``` #### Error Responses - **400 Bad Request**: Invalid input. - **404 Not Found**: Repository not found. - **422 Unprocessable Entity**: Validation error. - **500 Internal Server Error**: Server encountered an error. ``` -------------------------------- ### Install Python Dependencies with uv Source: https://docs.codegen.com/sandboxes/setup-commands This command uses the `uv` package manager to create a virtual environment with a specific Python version (3.12) and install project dependencies from a requirements file. It also includes options for refreshing and upgrading packages. ```bash # Install Python 3.12 and create a virtual environment uv venv --python=3.12 # Activate the virtual environment source .venv/bin/activate # Install dependencies uv pip install -r requirements.txt --refresh --upgrade ``` -------------------------------- ### Install Codegen CLI Source: https://docs.codegen.com/introduction/cli Installs the Codegen CLI using the `uv` package manager. Ensure `uv` is installed and configured in your environment. ```bash uv tool install codegen ``` -------------------------------- ### Python SDK Authentication Example Source: https://docs.codegen.com/api-reference/authentication This example shows how to initialize the Python SDK with your Organization ID and API token for authentication. ```APIDOC ## Python SDK Authentication Example ### Description Demonstrates how to initialize the Codegen Python SDK with your organization ID and API token. The SDK handles the authentication process automatically for subsequent requests. ### Method N/A (Initialization example) ### Endpoint N/A ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```python from codegen import Agent # Initialize with your credentials agent = Agent(org_id="YOUR_ORG_ID", token="YOUR_API_TOKEN") # The SDK handles authentication automatically task = agent.run(prompt="Fix the bug in user authentication") print(task) ``` ### Response #### Success Response (200) - **task_result** (string) - The result of the agent's task. #### Response Example ```json { "task_result": "Bug fixed successfully." } ``` ``` -------------------------------- ### Dockerfile for Codegen Base Image Setup Source: https://docs.codegen.com/sandboxes/base-image This Dockerfile defines the build process for the Codegen base image. It installs Python, Node.js, essential development tools, package managers, and configures system services like SSH and Nginx. It sets up environment variables for a seamless development experience within the sandbox. ```dockerfile ARG TARGETPLATFORM=linux/amd64 FROM --platform=$TARGETPLATFORM ghcr.io/astral-sh/uv:python3.13-bookworm # Set environment variables to prevent interactive prompts during installation ENV NVM_DIR=/usr/local/nvm \ NODE_VERSION=22.14.0 \ DEBIAN_FRONTEND=noninteractive \ NODE_OPTIONS="--max-old-space-size=8192" \ PYTHONUNBUFFERED=1 \ COREPACK_ENABLE_DOWNLOAD_PROMPT=0 \ PYTHONPATH="/usr/local/lib/python3.13/site-packages" \ IS_SANDBOX=True ENV PATH=$NVM_DIR/versions/node/$NODE_VERSION/bin:/usr/local/nvm:/usr/local/bin:$PATH ARG INVALIDATE_FILES_LAYER=1 # Copy configuration files and set permissions COPY sshd_config /etc/ssh/sshd_config COPY ssh_config /etc/ssh/ssh_config COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf COPY start.sh /usr/local/bin/start.sh COPY setup_ssh_user.sh /usr/local/bin/setup_ssh_user.sh COPY setup_ssh_keys.sh /usr/local/bin/setup_ssh_keys.sh COPY nginx.conf /etc/nginx/nginx.conf COPY error.html /usr/share/nginx/html/error.html COPY tmux_output_script.sh /usr/local/bin/tmux_output_script.sh # Install dependencies and set up environment in a single layer RUN apt-get update && apt-get install -y -o Dpkg::Options::="--force-confold" \ git \ curl \ fd-find \ gh \ lsof \ ripgrep \ openssh-server \ nginx-full \ fcgiwrap \ tmux \ nano \ vim \ supervisor \ netcat-openbsd \ && rm -rf /var/lib/apt/lists/* \ && mkdir -p -m 755 /etc/apt/keyrings \ && wget -nv -O- https://cli.github.com/packages/githubcli-archive-keyring.gpg | tee /etc/apt/keyrings/githubcli-archive-keyring.gpg > /dev/null \ && chmod go+r /etc/apt/keyrings/githubcli-archive-keyring.gpg \ && echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | tee /etc/apt/sources.list.d/github-cli.list > /dev/null \ # Set up environment variables and save it to /etc/profile.d/nvm.sh && echo "export NVM_DIR=\"$NVM_DIR\"" >> /etc/profile.d/nvm.sh \ && echo "[ -s \"$NVM_DIR/nvm.sh\" ] && \\. \"$NVM_DIR/nvm.sh\"" >> /etc/profile.d/nvm.sh \ && echo "export PATH=\"$NVM_DIR/versions/node/$NODE_VERSION/bin:$PATH\"" >> /etc/profile.d/nvm.sh \ && echo "export NVM_BIN=\"$NVM_DIR/versions/node/$NODE_VERSION/bin\"" >> /etc/profile.d/nvm.sh \ && echo "export NODE_VERSION=\"$NODE_VERSION\"" >> /etc/profile.d/nvm.sh \ && echo "export NODE_OPTIONS=\"--max-old-space-size=8192\"" >> /etc/profile.d/nvm.sh \ && echo "export DEBIAN_FRONTEND=noninteractive" >> /etc/profile.d/nvm.sh \ && echo "export PYTHONUNBUFFERED=1" >> /etc/profile.d/nvm.sh \ && echo "export COREPACK_ENABLE_DOWNLOAD_PROMPT=0" >> /etc/profile.d/nvm.sh \ && echo "export PYTHONPATH=\"/usr/local/lib/python3.13/site-packages\"" >> /etc/profile.d/nvm.sh \ && echo "export IS_SANDBOX=true" >> /etc/profile.d/nvm.sh \ && echo "export NPM_CONFIG_YES=true" >> /etc/profile.d/nvm.sh \ && echo "export PIP_NO_INPUT=1" >> /etc/profile.d/nvm.sh \ && echo "export YARN_ENABLE_IMMUTABLE_INSTALLS=false" >> /etc/profile.d/nvm.sh \ && chmod +x /etc/profile.d/nvm.sh \ # Run the SSH setup script && /usr/local/bin/setup_ssh_user.sh \ # Install nvm, Node.js, and code-server && mkdir -p $NVM_DIR \ && curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.5/install.sh | bash \ && . $NVM_DIR/nvm.sh \ && nvm install $NODE_VERSION \ && nvm use $NODE_VERSION \ && npm install -g yarn pnpm \ && corepack enable \ && corepack prepare yarn@stable --activate \ && corepack prepare pnpm@latest --activate \ && curl -fsSL https://raw.githubusercontent.com/coder/code-server/refs/tags/v4.99.1/install.sh | sh \ && uv tool install uvicorn[standard] ENTRYPOINT ["/usr/local/bin/start.sh"] ``` -------------------------------- ### Start Node.js Development Server for Web Preview Source: https://docs.codegen.com/sandboxes/web-preview This command starts a Node.js development server, typically used for web applications. It assumes a 'dev' script is defined in the project's package.json. The server should be configured to listen on port 3000 for Codegen's Web Preview to function correctly. ```bash # For a Node.js/npm project npm run dev ``` -------------------------------- ### Start Ruby on Rails Development Server for Web Preview Source: https://docs.codegen.com/sandboxes/web-preview This command starts a Ruby on Rails development server. It specifies the binding address to localhost (127.0.0.1) and the port to 3000, ensuring compatibility with Codegen's Web Preview feature. This command is used for Ruby on Rails applications. ```bash # For a Ruby on Rails project bundle exec rails server -b 127.0.0.1 -p 3000 ``` -------------------------------- ### Markdown Example for Agent Rules (AGENTS.md) Source: https://docs.codegen.com/settings/repo-rules This example demonstrates how to structure backend development rules within an AGENTS.md file. It covers database operations and API design conventions. This format is automatically detected by Codegen. ```markdown # Backend Development Rules ## Database - Use Prisma for database operations - Always use transactions for multi-step operations - Include proper error handling for all database calls ## API Design - Follow REST conventions - Use proper HTTP status codes - Include request/response validation ``` -------------------------------- ### Install Codegen Package (Bash) Source: https://docs.codegen.com/introduction/sdk Provides commands to install the 'codegen' Python package using different package managers: pip, pipx, and uv. These are essential for using the Codegen SDK and CLI. ```bash # Using pip pip install codegen # Using pipx (for CLI usage) pipx install codegen # Using uv uv pip install codegen # or uv tool install codegen ``` -------------------------------- ### REST API Authentication Example Source: https://docs.codegen.com/api-reference/authentication This example demonstrates how to include your API token in the Authorization header for REST API requests. ```APIDOC ## REST API Authentication Example ### Description This example shows how to authenticate REST API requests using a Bearer token in the `Authorization` header. ### Method GET (example, actual method depends on the endpoint) ### Endpoint https://api.codegen.com/v1/organizations/YOUR_ORG_ID/agent/run ### Parameters #### Query Parameters None #### Headers - **Authorization** (string) - Required - Bearer token format: `Bearer YOUR_API_TOKEN` ### Request Example ```bash curl -H "Authorization: Bearer YOUR_API_TOKEN" \ "https://api.codegen.com/v1/organizations/YOUR_ORG_ID/agent/run" ``` ### Response #### Success Response (200) - **status** (string) - Indicates the success of the operation. #### Response Example ```json { "status": "success" } ``` ``` -------------------------------- ### Install and Run Codegen CLI for Claude Source: https://docs.codegen.com/capabilities/claude-code Steps to install the Codegen CLI, authenticate your account, and run Claude with full telemetry. This enables cloud logging and integration access for your local Claude sessions. ```bash uv tool install codegen codegen login codegen claude "Help me refactor this authentication module" ``` -------------------------------- ### OpenAPI Specification for Get Check Suite Settings Source: https://docs.codegen.com/api-reference/repositories/get-check-suite-settings This OpenAPI 3.0 specification defines the GET /v1/organizations/{org_id}/repos/check-suite-settings endpoint. It details the request parameters (repo_id), response structure for a 200 OK (CheckSuiteSettingsResponse) and 422 Unprocessable Entity (HTTPValidationError), including schemas and examples. ```yaml paths: /v1/organizations/{org_id}/repos/check-suite-settings: get: servers: - url: https://api.codegen.com description: Codegen API request: security: [] parameters: query: repo_id: schema: type: integer required: true title: Repo Id description: Repository ID response: '200': application/json: schemaArray: - type: object properties: check_retry_count: allOf: - type: integer title: Check Retry Count ignored_checks: allOf: - items: type: string type: array title: Ignored Checks check_retry_counts: allOf: - additionalProperties: type: integer type: object title: Check Retry Counts custom_prompts: allOf: - additionalProperties: type: string type: object title: Custom Prompts high_priority_apps: allOf: - items: type: string type: array title: High Priority Apps available_check_suite_names: allOf: - items: type: string type: array title: Available Check Suite Names title: CheckSuiteSettingsResponse description: Response model for check suite settings. refIdentifier: '#/components/schemas/CheckSuiteSettingsResponse' requiredProperties: - check_retry_count - ignored_checks - check_retry_counts - custom_prompts - high_priority_apps - available_check_suite_names examples: example: value: check_retry_count: 123 ignored_checks: - check_retry_counts: {} custom_prompts: {} high_priority_apps: - available_check_suite_names: - description: Successful Response '422': application/json: schemaArray: - type: object properties: detail: allOf: - items: $ref: '#/components/schemas/ValidationError' type: array title: Detail title: HTTPValidationError refIdentifier: '#/components/schemas/HTTPValidationError' examples: example: value: detail: - loc: - msg: type: description: Validation Error deprecated: false type: path components: schemas: ValidationError: properties: loc: items: anyOf: - type: string - type: integer type: array title: Location msg: type: string title: Message type: type: string title: Error Type type: object required: - loc - msg - type title: ValidationError ``` -------------------------------- ### GET /v1/organizations/{org_id}/cli/rules Source: https://docs.codegen.com/api-reference/cli-rules/get-cli-rules Retrieves organization rules and user custom prompts for CLI applications. These rules are used by AI agents to guide their behavior and responses. ```APIDOC ## GET /v1/organizations/{org_id}/cli/rules ### Description Fetches organization-specific rules and user-specific custom prompts for CLI applications. These are used in prompts for AI agents. ### Method GET ### Endpoint /v1/organizations/{org_id}/cli/rules ### Parameters #### Path Parameters - **org_id** (integer) - Required - The ID of the organization. #### Query Parameters (No query parameters defined) #### Header Parameters - **authorization** (any) - Optional - Authorization token. ### Request Example (No request body example provided as it is a GET request without a body) ### Response #### Success Response (200) - **organization_rules** (string | null) - Organization-specific rules. - **user_custom_prompt** (string | null) - User-specific custom prompt. #### Response Example ```json { "organization_rules": "", "user_custom_prompt": "" } ``` #### Error Responses - **403 Forbidden**: Returned if the user does not have access to the organization. ```json { "message": "You do not have access to this organization.", "status_code": 403 } ``` - **422 Unprocessable Entity**: Returned for validation errors. ```json { "detail": [ { "loc": [ "" ], "msg": "", "type": "" } ] } ``` - **429 Too Many Requests**: Returned if the rate limit is exceeded. ```json { "message": "Rate limit exceeded. Please try again later.", "status_code": 429 } ``` ``` -------------------------------- ### Initialize and Run Agent with Codegen SDK (Python) Source: https://docs.codegen.com/introduction/sdk Demonstrates how to initialize the Codegen Agent using an organization ID and API token, run a task with a prompt, and check the task's status and result. Requires the 'codegen' package. ```python from codegen import Agent # Initialize the Agent with your organization ID and API token agent = Agent(org_id="...", token="...") # Run an agent with a prompt task = agent.run(prompt="Leave a review on PR #123") # Check the initial status print(task.status) # Refresh the task to get updated status (tasks can take time) task.refresh() if task.status == "completed": print(task.result) # Result often contains code, summaries, or links ``` -------------------------------- ### Start Python Django Development Server for Web Preview Source: https://docs.codegen.com/sandboxes/web-preview This command initiates a Python Django development server. It explicitly binds the server to localhost (127.0.0.1) and port 3000, which is required for Codegen's Web Preview. This is suitable for Django projects requiring a web server. ```bash # For a Python/Django project python manage.py runserver 127.0.0.1:3000 ``` -------------------------------- ### GET /v1/organizations/{org_id}/agent/run/{agent_run_id} Source: https://docs.codegen.com/api-reference/agents/get-agent-run Retrieves information about a specific agent run within an organization. This endpoint allows you to get details such as status, creation time, results, and associated pull requests. ```APIDOC ## GET /v1/organizations/{org_id}/agent/run/{agent_run_id} ### Description Retrieves information about a specific agent run within an organization. This endpoint allows you to get details such as status, creation time, results, and associated pull requests. ### Method GET ### Endpoint /v1/organizations/{org_id}/agent/run/{agent_run_id} ### Parameters #### Path Parameters - **org_id** (integer) - Required - The ID of the organization. - **agent_run_id** (integer) - Required - The ID of the agent run. #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) - **id** (integer) - The ID of the agent run. - **organization_id** (integer) - The ID of the organization associated with the agent run. - **status** (string | null) - The current status of the agent run. - **created_at** (string | null) - The timestamp when the agent run was created. - **web_url** (string | null) - A URL to view the agent run details. - **result** (string | null) - The result of the agent run. - **summary** (string | null) - A summary of the agent run. - **source_type** (ApiAgentRunSourceType | null) - The type of source for the agent run. - **github_pull_requests** (array of GithubPullRequestResponse | null) - A list of associated GitHub pull requests. - **metadata** (object | null) - Additional metadata for the agent run. #### Response Example ```json { "id": 123, "organization_id": 123, "status": "completed", "created_at": "2023-10-27T10:00:00Z", "web_url": "https://app.codegen.com/runs/123", "result": "Agent run finished successfully.", "summary": "Code generated and reviewed.", "source_type": "LOCAL", "github_pull_requests": [ { "id": 456, "title": "Feature Implementation", "url": "https://github.com/user/repo/pull/1", "created_at": "2023-10-26T09:00:00Z", "head_branch_name": "feature-branch" } ], "metadata": {} } ``` #### Error Response (403) - **message** (string) - Error message indicating lack of access. - **status_code** (integer) - The HTTP status code (403). #### Error Response Example (403) ```json { "message": "You do not have access to this organization.", "status_code": 403 } ``` #### Error Response (404) - **message** (string) - Error message indicating the agent run was not found. - **status_code** (integer) - The HTTP status code (404). #### Error Response Example (404) ```json { "message": "Agent run not found.", "status_code": 404 } ``` ``` -------------------------------- ### GET /v1/organizations/{org_id}/repos/check-suite-settings Source: https://docs.codegen.com/api-reference/repositories/get-check-suite-settings Retrieves the check suite settings for a given repository. This includes retry counts, ignored checks, and high-priority applications. ```APIDOC ## GET /v1/organizations/{org_id}/repos/check-suite-settings ### Description Get check suite settings for a repository. ### Method GET ### Endpoint https://api.codegen.com/v1/organizations/{org_id}/repos/check-suite-settings ### Parameters #### Query Parameters - **repo_id** (integer) - Required - Repository ID ### Request Example ```json { "repo_id": 123 } ``` ### Response #### Success Response (200) - **check_retry_count** (integer) - The number of times a check should be retried. - **ignored_checks** (array[string]) - A list of checks that are ignored. - **check_retry_counts** (object) - A map of check names to their retry counts. - **custom_prompts** (object) - A map of check names to their custom prompts. - **high_priority_apps** (array[string]) - A list of high-priority applications. - **available_check_suite_names** (array[string]) - A list of available check suite names. #### Response Example ```json { "check_retry_count": 123, "ignored_checks": [ "" ], "check_retry_counts": {}, "custom_prompts": {}, "high_priority_apps": [ "" ], "available_check_suite_names": [ "" ] } ``` #### Error Response (422) - **detail** (array[object]) - Details about validation errors. - **loc** (array) - The location of the error. - **msg** (string) - The error message. - **type** (string) - The error type. #### Response Example ```json { "detail": [ { "loc": [ "" ], "msg": "", "type": "" } ] } ``` ``` -------------------------------- ### POST /websites/codegen/analyze_sandbox_logs Source: https://docs.codegen.com/api-reference/sandbox/analyze-sandbox-logs Initiates an AI agent to analyze sandbox setup logs. The analysis is asynchronous, and the results can be retrieved later using the provided agent run ID. This endpoint is rate-limited to 5 requests per minute. ```APIDOC ## POST /websites/codegen/analyze_sandbox_logs ### Description Creates an AI agent that will analyze the setup logs from a sandbox, identify any errors, provide insights about what went wrong, and suggest potential solutions. The analysis runs asynchronously and results can be retrieved using the returned agent run ID. ### Method POST ### Endpoint /websites/codegen/analyze_sandbox_logs ### Parameters #### Query Parameters - **rate_limit_info** (string) - Optional - Information about the rate limit. #### Request Body - **logs** (string) - Required - The sandbox setup logs to be analyzed. ### Request Example ```json { "logs": "2023-10-27 10:00:00 INFO: Sandbox environment started. 2023-10-27 10:01:00 ERROR: Failed to connect to database. Connection refused." } ``` ### Response #### Success Response (200) - **agent_run_id** (string) - The unique identifier for the asynchronous analysis run. - **message** (string) - A confirmation message indicating the analysis has started. #### Response Example ```json { "agent_run_id": "run_abc123xyz789", "message": "Sandbox log analysis initiated successfully." } ``` ``` -------------------------------- ### Create Virtual Environment with Specific Python Source: https://docs.codegen.com/sandboxes/setup-commands This command creates a virtual environment named 'venv_312' using Python 3.12 and activates it. This is useful for ensuring compatibility with packages that require older Python versions. ```bash # Create a virtual environment with a specific Python version python3.12 -m venv venv_312 source venv_312/bin/activate # Verify the Python version python --version ``` -------------------------------- ### Get Organizations API Endpoint (OpenAPI 3.0) Source: https://docs.codegen.com/api-reference/organizations/get-organizations Defines the GET /v1/organizations endpoint for retrieving a list of organizations. Supports pagination via 'skip' and 'limit' query parameters and includes responses for successful data retrieval, validation errors, and rate limiting. ```yaml paths: path: /v1/organizations method: get servers: - url: https://api.codegen.com description: Codegen API request: security: [] parameters: path: {} query: skip: schema: - type: integer required: false title: Skip minimum: 0 default: 0 limit: schema: - type: integer required: false title: Limit maximum: 100 minimum: 1 default: 100 header: authorization: schema: - type: any required: false title: Authorization cookie: {} body: {} response: '200': application/json: schemaArray: - type: object properties: items: allOf: - items: $ref: '#/components/schemas/OrganizationResponse' type: array title: Items total: allOf: - type: integer title: Total page: allOf: - type: integer title: Page size: allOf: - type: integer title: Size pages: allOf: - type: integer title: Pages title: Page[OrganizationResponse] refIdentifier: '#/components/schemas/Page_OrganizationResponse_' requiredProperties: - items - total - page - size - pages examples: example: value: items: - id: 123 name: settings: enable_pr_creation: true enable_rules_detection: true total: 123 page: 123 size: 123 pages: 123 description: Successful Response '422': application/json: schemaArray: - type: object properties: detail: allOf: - items: $ref: '#/components/schemas/ValidationError' type: array title: Detail title: HTTPValidationError refIdentifier: '#/components/schemas/HTTPValidationError' examples: example: value: detail: - loc: - msg: type: description: Validation Error '429': application/json: schemaArray: - type: object properties: message: allOf: - type: string title: Message default: Rate limit exceeded. Please try again later. status_code: allOf: - type: integer title: Status Code default: 429 title: APIRateLimitErrorResponse refIdentifier: '#/components/schemas/APIRateLimitErrorResponse' examples: example: value: message: Rate limit exceeded. Please try again later. status_code: 429 description: Too Many Requests deprecated: false type: path components: schemas: OrganizationResponse: properties: id: type: integer title: Id name: type: string title: Name settings: $ref: '#/components/schemas/OrganizationSettings' type: object required: - id - name - settings title: OrganizationResponse description: Represents an organization in API responses OrganizationSettings: properties: enable_pr_creation: type: boolean title: Enable Pr Creation default: true enable_rules_detection: type: boolean title: Enable Rules Detection default: true type: object title: OrganizationSettings ValidationError: properties: loc: items: anyOf: - type: string - type: integer type: array title: Location msg: type: string title: Message type: type: string title: Error Type type: object required: - loc - msg - type title: ValidationError ``` -------------------------------- ### POST /v1/organizations/{org_id}/agent/run/resume Source: https://docs.codegen.com/api-reference/overview Resumes a previous agent run with a follow-up prompt. ```APIDOC ## POST /v1/organizations/{org_id}/agent/run/resume ### Description Continues an existing agent run by providing an additional prompt, allowing for iterative development. ### Method POST ### Endpoint /v1/organizations/{org_id}/agent/run/resume #### Path Parameters - **org_id** (string) - Required - The unique identifier for the organization. #### Request Body - **agent_run_id** (integer) - Required - The ID of the agent run to resume. - **prompt** (string) - Required - The follow-up instruction for the agent. ### Request Example ```json { "agent_run_id": 456, "prompt": "Also add unit tests for the error handling" } ``` ### Response #### Success Response (200) - **new_agent_run_id** (integer) - The ID of the new agent run created for the resume action. - **status** (string) - The initial status of the resumed agent run. #### Response Example ```json { "new_agent_run_id": 910, "status": "pending" } ``` ``` -------------------------------- ### Login to Codegen CLI Source: https://docs.codegen.com/introduction/cli Authenticates the Codegen CLI with your API token. Supports interactive login or direct token input. Obtain your API token from the authentication guide. ```bash # Interactive login codegen login # Direct token login codegen login --token YOUR_API_TOKEN ``` -------------------------------- ### HTTP Request: Get Agent Run Logs Source: https://docs.codegen.com/api-reference/agent-run-logs This snippet demonstrates how to make an HTTP GET request to the Agent Run Logs API endpoint. It includes placeholders for your organization ID, agent run ID, and API token, and shows how to include these in the URL and Authorization header. ```bash GET /v1/organizations/{org_id}/agent/run/{agent_run_id}/logs HTTP/1.1 Host: api.codegen.com Authorization: Bearer YOUR_API_TOKEN ``` -------------------------------- ### POST /v1/organizations/{org_id}/agent/run Source: https://docs.codegen.com/api-reference/agents/create-agent-run Initiates a new agent run within a specified organization. This endpoint allows you to provide a prompt, optional images, metadata, repository ID, model, and agent type to guide the agent's execution. ```APIDOC ## POST /v1/organizations/{org_id}/agent/run ### Description Initiates a new agent run within a specified organization. This endpoint allows you to provide a prompt, optional images, metadata, repository ID, model, and agent type to guide the agent's execution. ### Method POST ### Endpoint https://api.codegen.com/v1/organizations/{org_id}/agent/run ### Parameters #### Path Parameters - **org_id** (integer) - Required - The ID of the organization. #### Query Parameters None. #### Header Parameters - **authorization** (any) - Optional - Authorization token for the request. #### Request Body - **prompt** (string) - Required - The prompt for the agent. - **images** (array of strings) - Optional - A list of base64 encoded data URIs representing images. - **metadata** (object) - Optional - Arbitrary JSON metadata to be stored with the agent run. - **repo_id** (integer) - Optional - ID of the repository to use for the agent run. - **model** (string) - Optional - Model to use for this agent run (uses org default if not specified). - **agent_type** (string) - Optional - Type of agent to use for this agent run (e.g., `codegen`, `claude_code`). Uses org default if not specified. ### Request Example ```json { "prompt": "", "images": [ "" ], "metadata": {}, "repo_id": 123, "model": "", "agent_type": "codegen" } ``` ### Response #### Success Response (200) - **id** (integer) - The ID of the agent run. - **organization_id** (integer) - The ID of the organization. - **status** (string) - The status of the agent run. - **created_at** (string) - The timestamp when the agent run was created. - **web_url** (string) - A URL to view the agent run results. - **result** (string) - The result of the agent run. - **summary** (string) - A summary of the agent run. - **source_type** (string) - The type of source used for the agent run. - **github_pull_requests** (array of objects) - A list of associated GitHub pull requests. - **metadata** (object) - Metadata associated with the agent run. #### Response Example ```json { "id": 12345, "organization_id": 1, "status": "completed", "created_at": "2023-10-27T10:00:00Z", "web_url": "https://app.codegen.com/runs/12345", "result": "Agent run completed successfully.", "summary": "Code generated based on prompt.", "source_type": "api", "github_pull_requests": [], "metadata": {} } ``` ``` -------------------------------- ### GET /v1/organizations Source: https://docs.codegen.com/api-reference/organizations/get-organizations Retrieves a paginated list of organizations. Supports filtering and sorting. ```APIDOC ## GET /v1/organizations ### Description Retrieves a paginated list of organizations. Supports filtering and sorting. ### Method GET ### Endpoint https://api.codegen.com/v1/organizations ### Parameters #### Query Parameters - **skip** (integer) - Optional - Number of records to skip. Defaults to 0. - **limit** (integer) - Optional - Maximum number of records to return. Defaults to 100. Maximum value is 100, minimum is 1. - **authorization** (any) - Optional - Authentication token for accessing the API. ### Request Example ```json { "example": "No request body for GET request" } ``` ### Response #### Success Response (200) - **items** (array) - A list of OrganizationResponse objects. - **total** (integer) - The total number of organizations available. - **page** (integer) - The current page number. - **size** (integer) - The number of organizations per page. - **pages** (integer) - The total number of pages. #### Response Example ```json { "items": [ { "id": 123, "name": "", "settings": { "enable_pr_creation": true, "enable_rules_detection": true } } ], "total": 123, "page": 123, "size": 123, "pages": 123 } ``` #### Error Response (422) - **detail** (array) - A list of validation errors. #### Error Response Example (422) ```json { "detail": [ { "loc": [ "" ], "msg": "", "type": "" } ] } ``` #### Error Response (429) - **message** (string) - Describes the error, e.g., 'Rate limit exceeded. Please try again later.' - **status_code** (integer) - The HTTP status code, typically 429. #### Error Response Example (429) ```json { "message": "Rate limit exceeded. Please try again later.", "status_code": 429 } ``` ``` -------------------------------- ### API Source Types Source: https://docs.codegen.com/api-reference/agents/list-agent-runs Enumerates the possible source types for agent runs. ```APIDOC ## ApiAgentRunSourceType ### Description Represents the different sources that can initiate an agent run. ### Enum Values - LOCAL - SLACK - GITHUB - GITHUB_CHECK_SUITE - GITHUB_PR_REVIEW - LINEAR - API - CHAT - JIRA - CLICKUP - MONDAY - SETUP_COMMANDS ```