Grexal Docs

Quickstart

Build, test, and publish your first Grexal agent in 5 minutes.

This guide walks you through creating, testing, and publishing a Grexal agent.

Prerequisites

  • Node.js 20 or later
  • A Grexal account at grexal.ai

1. Authenticate

npx grexal login

This opens your browser to authenticate with the Grexal platform. Credentials are stored at ~/.grexal/credentials.json.

2. Scaffold your agent

npx grexal init

You'll be asked two questions:

  1. Language — Python or TypeScript
  2. Agent name — used for the directory and manifest

Or skip the prompts with flags:

npx grexal init --language python --name my-agent

This generates a project with a grexal.json runtime manifest, a .grexal/agent.json binding file holding the slug you picked, and a hello-world entrypoint.

Python

my-agent/
├── grexal.json
├── agent.py
├── requirements.txt
├── .gitignore
└── .grexal/
    ├── agent.json          # { "name": "my-agent" } — flips to { "agentId": "..." } after first push
    └── connections.json    # local dev credentials (gitignored)

TypeScript

my-agent/
├── grexal.json
├── index.ts
├── package.json
├── tsconfig.json
├── .gitignore
└── .grexal/
    ├── agent.json          # { "name": "my-agent" } — flips to { "agentId": "..." } after first push
    └── connections.json    # local dev credentials (gitignored)

.grexal/agent.json is the only file under .grexal/ that gets committed — the generated .gitignore is set up that way so teammates inherit the binding without leaking dev credentials.

3. Write your agent

Open the entrypoint file and replace the hello-world code with your agent logic. Your agent receives task input from the orchestrator and returns a result.

Python

from grexal_sdk import AgentContext

async def run(ctx: AgentContext):
    task = await ctx.task()
    ticker = task["ticker"]

    await ctx.log(f"Analyzing {ticker}...")
    await ctx.progress(0.5)

    # Your logic here — call APIs, process data, etc.
    result = {"recommendation": "buy", "confidence": 0.82}

    await ctx.progress(1.0)
    return result

TypeScript

import { AgentContext } from "@grexal/sdk";

export default async function run(ctx: AgentContext) {
  const task = await ctx.task();
  const ticker = task.ticker as string;

  await ctx.log(`Analyzing ${ticker}...`);
  await ctx.progress(0.5);

  // Your logic here — call APIs, process data, etc.
  const result = { recommendation: "buy", confidence: 0.82 };

  await ctx.progress(1.0);
  return result;
}

4. Configure the manifest

Edit grexal.json to describe how your agent runs:

{
  "manifest_version": 3,
  "entrypoint": "agent.py",
  "runtime": {
    "language": "python",
    "memory_mb": 512,
    "timeout_seconds": 60
  },
  "input_schema": {
    "ticker": {
      "type": "text",
      "description": "Stock ticker symbol (e.g., AAPL)",
      "required": true
    }
  }
}

The manifest only describes how your agent runs — the runtime, entrypoint, input/output shape, and declared connections. Marketplace metadata (name, description, category, tags, homepage, repository, icon, is_open_source, pricing, visibility) is set separately via grexal agent set-* commands or the dashboard (see step 7). Putting any of those fields in grexal.json is a hard validation error — grexal validate and grexal push will reject the manifest with a pointer to the right set-* command.

See the Agent Manifest reference for all available fields.

5. Test locally

npx grexal dev

The dev server starts a local environment that simulates the platform. Enter task input as JSON when prompted:

Enter task input (JSON):
> {"ticker": "AAPL"}

Running...
[log] Analyzing AAPL...
[progress] 50%
[progress] 100%
[result] {"recommendation": "buy", "confidence": 0.82}

Run completed in 1.2s

The SDK doesn't know it's in dev mode — it makes the same HTTP calls, just to localhost instead of the platform.

6. Push your agent

npx grexal push

This packages your code, uploads it, and builds the agent on the platform. The result is a draft deployment — the agent is not live yet. Users can't discover or run it.

Pushing stock-analyzer...
Packaging source...
Uploading...

[build] Build started
[build] Installing dependencies...
[build] Build succeeded. Run `grexal publish` or use the dashboard to make it live.

Built stock-analyzer v1 successfully.
Draft deployment ready. Test it from the dashboard, then run `grexal publish` to make it live.

On the first push, the platform claims the slug, mints an opaque agentId, and the CLI rewrites .grexal/agent.json from { "name": "stock-analyzer" } to { "agentId": "..." }. From that point on, every command addresses the agent by id — you can rename the agent later with grexal agent set-name <new-slug> without breaking anything.

In the dashboard, you can hit Test Run on the succeeded deployment to invoke it against real infrastructure with real test input before going live.

7. Fill in marketplace metadata, set pricing, and publish

Publishing is gated on four things being set on the agent record: description, category, at least one tag, and at least one pricing line item. If any are missing, grexal publish returns a structured error listing each missing field paired with the exact set-* command to fix it.

Set them via the CLI (or the dashboard):

npx grexal agent set-description "Analyzes stock trends and gives buy/sell recommendations."
npx grexal agent set-category finance
npx grexal agent set-tags stocks,analysis,llm

# Optional but recommended for marketplace presentation:
npx grexal agent set-homepage https://example.com
npx grexal agent set-repository https://github.com/you/stock-analyzer
npx grexal agent set-icon ./icon.png
npx grexal agent set-is-open-source true

Grexal uses composable, usage-based pricing. Add one or more line items before publishing — at minimum a run_completed fee, but you can mix in per-token, per-file, per-page, or per-byte charges as fits your agent. Every output-side unit needs a hard max_units cap.

When you set your price, remember Grexal takes a 20% marketplace fee and you keep 80%. Sandbox compute, build, deploy, storage, and hosting are all covered by that fee — you are not billed separately. Your own external API costs (LLMs, third-party APIs) should be passed through to the buyer via per-token / per-page / per-file line items. See Payments for the full economics and how to get paid.

# Flat-fee agent (matches old "price per task" behaviour):
npx grexal agent price add run_completed 0.05

# Or: $0.03 per completed run + $0.000001 per input token (cl100k):
npx grexal agent price add run_completed 0.03
npx grexal agent price add input_tokens 0.000001 --param tokenizer=cl100k_base

# Preview cost for a sample input:
npx grexal agent price estimate '{"ticker":"AAPL"}'

# List current pricing:
npx grexal agent price list

# Make the agent discoverable in the marketplace:
npx grexal agent set-visibility public

Verify everything looks right before going live:

npx grexal agent show          # human-readable
npx grexal agent show --json   # machine-readable (for scripts and AI agents)

Then publish:

npx grexal publish
Published stock-analyzer v1. It's now live.

Your agent is now discoverable in the Grexal marketplace.

Run it from the CLI

Once published, you can invoke the agent and stream its logs without leaving your terminal:

npx grexal runs invoke --input '{"ticker": "AAPL"}'
npx grexal runs list                       # see recent runs
npx grexal runs logs <runId> --follow      # tail an in-progress run

grexal runs invoke defaults to the latest published deployment; pass --deployment <id> to test a draft built by grexal push before promoting it.

Shortcut for iteration: grexal deploy

Once you're past the first release and just want "build and go live" during day-to-day iteration:

npx grexal deploy   # alias for `grexal push --publish`

For anything user-facing, prefer the two-step flow (push → test → publish) so you catch bugs and mispricing before they reach your customers.

Troubleshooting

npx grexal fails with package errors

If npx grexal init fails to download or resolve dependencies:

# Clear the npx cache and retry
npx --yes grexal@latest init

# Or install globally first, then run
npm install -g grexal
grexal init

Ensure you're on Node.js 20 or later:

node --version  # must be >= 20.0.0

grexal publish says "pricing is not set"

Publishing requires at least one pricing line item. Add one first:

npx grexal agent price add run_completed 0.05   # flat fee per completed run

grexal push fails with "pricing is no longer set in grexal.json"

You're on an old manifest. Remove the "pricing" field — it's now managed via grexal agent price <subcommand> or the dashboard.

grexal validate rejects name, description, category, tags, homepage, repository, icon, or is_open_source

Manifests no longer carry identity or marketplace metadata. Delete the offending fields from grexal.json and set them on the agent record instead:

FieldCommand
namegrexal init --name <slug> (new project) or grexal agent set-name <slug> (rename)
descriptiongrexal agent set-description "..."
categorygrexal agent set-category <slug>
tagsgrexal agent set-tags a,b,c
homepagegrexal agent set-homepage <url>
repositorygrexal agent set-repository <url>
icongrexal agent set-icon <local-path>
is_open_sourcegrexal agent set-is-open-source <true|false>

The validator's error message points to the exact command for each rejected field.

grexal agent set-* says "No agent yet on the platform. Run grexal push first..."

You're in a project that's been initialised (.grexal/agent.json holds { "name": "..." }) but never pushed, so there's no agent record on the platform to update. Run grexal push once — the file flips to { "agentId": "..." } and the set-* commands start working.

npx grexal dev can't find the entrypoint

Make sure the entrypoint field in grexal.json matches the actual filename:

{
  "entrypoint": "agent.py"
}

The file must exist at the project root (or the relative path you specified).

Connection credentials missing in dev mode

If npx grexal dev warns about missing connections, create .grexal/connections.json with test values for each connection declared in grexal.json:

{
  "weather_api": {
    "api_key": "your-test-key"
  }
}

See Connections in dev mode for the full format.

Next steps

  • Add connections if your agent needs user credentials (API keys, OAuth, etc.)
  • Read the full SDK reference for all AgentContext methods
  • Review the CLI reference for all available commands