Overview
The/generate endpoint analyzes a repository and automatically generates an AGENTS.md file that describes its agent-usable capabilities, endpoints, and authentication requirements. It leverages AI providers (Gemini, Claude, OpenAI, or Beacon Cloud) to infer the repository’s functionality.
Endpoint
Rate Limiting
This endpoint is rate-limited to 20 requests per minute per IP address.Authentication
No direct authentication is required for the API endpoint itself. However:- AI provider API keys (e.g.,
GEMINI_API_KEY,CLAUDE_API_KEY,OPENAI_API_KEY) must be configured as environment variables on the server - When using the
beacon-ai-cloudprovider, payment verification is required (see Payment Flow section)
Request
Request Body
The request body should be a JSON object containing repository context and configuration.The name of the repository being analyzed.
The contents of the repository’s README file, if available.
An array of source file objects containing the repository’s code.Each object should have:
path(string): File path relative to repository rootlanguage(string): Programming language (e.g., “Rust”, “Python”, “TypeScript”)content(string): The file’s source code content
OpenAPI/Swagger specification content, if the repository has one.
Package manifest content (e.g., package.json, Cargo.toml, requirements.txt).
Content of an existing AGENTS.md file, if present. Used to preserve or enhance existing documentation.
The AI provider to use for inference. Options:
"gemini"- Google’s Gemini (default)"claude"- Anthropic’s Claude"openai"- OpenAI’s GPT models"beacon-ai-cloud"- Beacon’s hosted AI service (requires payment)
Example Request
Response
Success Response (200 OK)
Always
true for successful requests.The complete generated AGENTS.md file content as a string.
Structured manifest object containing parsed capabilities and endpoints.Properties:
name(string): Repository namedescription(string): Repository descriptionversion(string): Version numbercapabilities(array): List of agent-usable capabilitiesendpoints(array): API endpoints with methods and parametersauthentication(object): Authentication requirementsrate_limits(object): Rate limiting information
Example Success Response
Error Responses
402 Payment Required
Returned when usingbeacon-ai-cloud provider without valid payment.
x-payment-run-id: Unique run identifier for this generation requestx-payment-amount: Amount required in USDC (e.g., “0.09”)x-payment-currency: Always “USDC”x-payment-address-base: Base blockchain wallet addressx-payment-address-solana: Solana blockchain wallet address
409 Conflict
Returned when a transaction hash has already been used.429 Too Many Requests
Returned when rate limit is exceeded (>20 requests/minute).500 Internal Server Error
Returned when generation fails.Payment Flow (beacon-ai-cloud)
When using thebeacon-ai-cloud provider, a two-step payment flow is required:
Step 1: Initial Request (No Payment)
Send a generate request withprovider: "beacon-ai-cloud" but no payment headers.
The API returns a 402 Payment Required response with payment details in headers.
Step 2: Submit Payment
Send USDC to one of the provided wallet addresses:- Base blockchain: Use address from
x-payment-address-baseheader - Solana blockchain: Use address from
x-payment-address-solanaheader
x-payment-amount header (typically 0.09 USDC)
Step 3: Retry with Payment Proof
Resend the same request with payment verification headers:x-payment-txn-hash: Transaction hash from your USDC paymentx-payment-chain: Blockchain used ("base"or"solana")x-payment-run-id: Run ID from the initial 402 response
- Verify the payment on-chain
- Check that the transaction hasn’t been used before
- Process the generation request
- Mark the run as complete
Implementation Details
The endpoint (defined insrc/main.rs:204-297):
- Validates the provider and handles payment flow for
beacon-ai-cloud - Calls
inferrer::infer_capabilities()to analyze the repository using the specified AI provider - Generates the AGENTS.md file using
generator::generate_agents_md() - Returns both the raw markdown content and structured manifest
beacon-ai-cloud with successful payment, the run is marked complete in the database with the generated content.