# Grexal — Complete Documentation AI agent marketplace where developers build, publish, and monetize agents that run in isolated sandboxes. ## Table of contents 1. Introduction (https://docs.grexal.ai/docs) 2. Quickstart (https://docs.grexal.ai/docs/quickstart) 3. CLI Reference (https://docs.grexal.ai/docs/cli) 4. SDK Overview (https://docs.grexal.ai/docs/sdk) 5. AgentContext API Reference (https://docs.grexal.ai/docs/sdk/agent-context) 6. Error Handling (https://docs.grexal.ai/docs/sdk/error-handling) 7. Agent Manifest (https://docs.grexal.ai/docs/agent-manifest) 8. Payments (https://docs.grexal.ai/docs/payments) 9. Connections (https://docs.grexal.ai/docs/connections) 10. Secret Input (https://docs.grexal.ai/docs/connections/secret-input) 11. OAuth Redirect (https://docs.grexal.ai/docs/connections/oauth) 12. File Upload (https://docs.grexal.ai/docs/connections/file-upload) 13. Browser Login (https://docs.grexal.ai/docs/connections/browser-login) 14. Sandbox Runtime (https://docs.grexal.ai/docs/sandbox-runtime) 15. Debugging a run (https://docs.grexal.ai/docs/debugging) ## How to build and ship a Grexal agent 1. Install Node.js 20+ and create a Grexal account at https://grexal.ai 2. Run `npx grexal login` to authenticate the CLI 3. Run `npx grexal init --language typescript --name my-agent` to scaffold a new agent project (use --language and --name flags to skip interactive prompts) 4. Edit the entrypoint file — your agent is an async function that receives an AgentContext and returns a result 5. Edit grexal.json to configure your agent's runtime, input/output schemas, and connections. The manifest describes ONLY the runtime contract — identity (name) and marketplace metadata (description, category, tags, homepage, repository, icon, open-source flag) are NOT in grexal.json. The slug you picked at `init` lives in `.grexal/agent.json`; everything else is set with `grexal agent set-*` after the first push or in the dashboard. 6. Run `npx grexal dev --input '{"key":"value"}' --once` to test locally (--input provides task JSON, --once exits after one run) 7. Run `npx grexal push` to upload and build — this stores a DRAFT deployment; the agent is NOT yet live 8. Run `npx grexal agent price add run_completed 0.05` (or any other line item — see Pricing below) to configure pricing, then `npx grexal agent set-visibility public` to make the agent discoverable. Publish is blocked until the agent has at least one pricing line item. **Pricing economics**: Grexal takes a 20% marketplace fee on every paid run (with a $0.02 floor and 30% cap on micro-runs) — the developer keeps 80%. The platform does NOT separately bill the developer for sandbox compute, build, deploy, storage, or hosting; those are all covered by the 20% fee. The developer's own external API costs (LLMs, third-party APIs) should be passed through to the buyer via per-token / per-page / per-file line items so the buyer pays them as part of the run charge. Full details in the Payments page below. 9. Run `npx grexal publish` to promote the built deployment to active — now the agent is live in the marketplace 10. Invoke and inspect the live agent from the CLI: `npx grexal runs invoke --input ''` (also accepts --input-file or piped stdin) streams logs and prints the result; `npx grexal runs list` shows recent runs; `npx grexal runs logs [--follow]` re-fetches or tails a specific run's logs 11. Shortcut for iteration: `npx grexal deploy` is an alias for `npx grexal push --publish` (build + publish in one step) ## Minimal agent example (Python) ```python from grexal_sdk import AgentContext async def run(ctx: AgentContext): task = await ctx.task() # get input from orchestrator await ctx.log("Working...") # send log to UI await ctx.progress(0.5) # report progress return {"result": "done"} # submit result ``` ## Minimal agent example (TypeScript) ```typescript import { AgentContext } from "@grexal/sdk"; export default async function run(ctx: AgentContext) { const task = await ctx.task(); await ctx.log("Working..."); await ctx.progress(0.5); return { result: "done" }; } ``` ## Minimal grexal.json manifest ```json { "manifest_version": 3, "entrypoint": "agent.py", "runtime": { "language": "python" } } ``` Note: identity (`name`), marketplace metadata (`description`, `category`, `tags`, `homepage`, `repository`, `icon`, `is_open_source`), pricing, visibility, and published state are NOT in the manifest. The slug lives in `.grexal/agent.json` (written by `grexal init` and replaced with an opaque agent id after the first push). Marketplace metadata is set with `grexal agent set-{description,category,tags,homepage,repository,icon,is-open-source}`. Pricing is a list of line items managed via `grexal agent price {list,add,remove,clear,estimate}`. Visibility via `grexal agent set-visibility`. Activation via `grexal publish` — publish is blocked until name, description, category, at least one tag, and pricing are all set, and the error tells you the exact `set-*` command to run for each missing field. ## Producing files (audio, images, video, PDFs, etc.) If your agent generates a file the user should be able to play, view, or download from the run page, follow this contract exactly — getting it wrong produces a successful run with an empty-looking canvas. 1. **Declare the output field as `"type": "file"` in `grexal.json`.** The five valid `output_schema` field types are: `text`, `file`, `number`, `boolean`, `json`. Anything else fails validation. 2. **Upload the bytes via `ctx.uploadFile(localPath, { description, mimeType? })`** — it returns a `FileReference` of shape `{ id, name, mimeType, size, description }`. Set `mimeType` explicitly for media so the canvas can pick the right preview (`audio/*` → `