Running Local Development

Run your framework dev script with Agentuity environment wiring.

agentuity dev runs your framework's dev script as a child process and patches Agentuity values into that process's environment. The framework keeps owning the dev server, hot reload, and the route table. Agentuity's job is to wire AGENTUITY_SDK_KEY and the AI Gateway base URLs in front of your provider SDKs.

agentuity dev

These examples show agentuity ... for readability. If the CLI is project-local, run the same command through your package-manager exec wrapper, for example npx agentuity ..., bunx agentuity ..., pnpm exec agentuity ..., or yarn exec agentuity .... See Local versus global CLI for install and undo commands.

What it runs

The CLI reads package.json, picks the package manager from the lockfile in the project root, and runs the chosen script:

Lockfile presentRunner used
bun.lock or bun.lockbbun run <script>
pnpm-lock.yamlpnpm run <script>
yarn.lockyarn <script>
package-lock.jsonnpm run <script>
Nonebun run <script>

The default script name is dev. Use --script when your dev script does something other than starting your framework, or when you want a non-standard script:

jsonpackage.json
{
  "scripts": {
    "dev": "agentuity dev --script dev:start",
    "dev:start": "next dev --port 3000"
  }
}

This is the recommended pattern for existing apps. Keep your real dev command in dev:start and let dev wrap it through Agentuity. agentuity dev and npm run dev then do the same thing.

If the named script is missing, the CLI prints the available scripts and exits.

Local Environment Loading

The CLI looks up AGENTUITY_SDK_KEY in your .env files using the active profile. The default profile is production. The local profile (local) loads a different file order so dev overrides do not bleed into other profiles.

ProfileFile order (highest priority first)
local (and NODE_ENV is not production).env.local.env.development.env
any other profile, or NODE_ENV=production.env.<profile>.env.env.production

Switch profiles with --profile <name> or the AGENTUITY_PROFILE env var. The framework dev server reads its own variables. The CLI does not parse .env for your app, only for the SDK key it needs to wire the gateway.

If no project SDK key is found, the CLI falls back to your CLI auth key for gateway routing and reminds you to run agentuity project import so the project gets its own key.

AI Gateway in Local Dev

agentuity dev automatically injects env vars for the SDKs that read provider API key and base URL values from process env. Other AI SDK providers need an explicit provider factory or a provider-owned key.

ProviderRaw SDKAI SDK moduleLocal dev wiring
OpenAIopenai@ai-sdk/openaienv vars patched into the dev child
Anthropic@anthropic-ai/sdk@ai-sdk/anthropicenv vars patched into the dev child
Groqgroq-sdk@ai-sdk/groqenv vars patched into the dev child

For OpenAI, Anthropic, and Groq, the automatic patch only runs when the provider API key is missing or already equals AGENTUITY_SDK_KEY. If you set a real provider key in .env, the CLI leaves it alone and your call goes straight to that provider.

For provider SDKs outside the automatic patch list, configure the provider factory yourself. Use provider-owned keys unless your project has a confirmed Agentuity gateway base URL for that provider:

import { createGoogleGenerativeAI } from '@ai-sdk/google';
 
const apiKey = process.env.GOOGLE_GENERATIVE_AI_API_KEY;
 
if (!apiKey) {
  throw new Error('Set GOOGLE_GENERATIVE_AI_API_KEY.');
}
 
export const google = createGoogleGenerativeAI({
  apiKey,
});

Port

agentuity dev sets PORT for the child process. The default is 3000. Pass --port when your framework should listen elsewhere:

agentuity dev --port 4321

Some frameworks ignore PORT and require a CLI flag in the dev script itself. Our SvelteKit, React Router, and TanStack Start examples use dev:start wrappers with --port 3000 for that reason. Next.js can read PORT directly, though next dev --port 3000 is also valid when you want the port pinned in the script.

Public Dev URL

By default, agentuity dev asks whether to expose the dev server through a public Gravity URL. The answer is stored in agentuity.json:

jsonagentuity.json
{
  "devmode": {
    "public": false
  }
}

Force a public URL for the current run:

agentuity dev --public

When the tunnel starts, the CLI prints both URLs and passes these values to the child process:

VariableValue
AGENTUITY_DEVMODE_URLPublic Gravity URL, such as https://abc.agentuity-us.live
AGENTUITY_DEVMODE_HOSTNAMEPublic hostname without the scheme

Vite-based apps should install @agentuity/vite and include the plugin in vite.config.ts. The plugin reads AGENTUITY_DEVMODE_HOSTNAME, adds the public hostname to Vite's allowed hosts, and configures HMR over wss.

typescriptvite.config.ts
import { agentuity } from '@agentuity/vite';
import { defineConfig } from 'vite';
 
export default defineConfig({
  plugins: [agentuity()],
});

Validate Project Shape

When you want to confirm a directory looks right without registering it or writing files, run import in validate-only mode:

agentuity project import --validate-only

The check accepts a package.json with at least one of name, dependencies, or devDependencies, or an agentuity/ subdirectory containing a package.json. Nothing is written and nothing is created in the cloud.

Local vs Deployed

AspectLocal (agentuity dev)Deployed
ProcessYour framework dev script as a childThe command from .agentuity/launch.json
AGENTUITY_SDK_KEYRead from .env (profile-aware) or CLI authInjected by the platform
Gateway base URLsOpenAI, Anthropic, and Groq env pairs patched into the child process when no provider key is set; other AI SDK providers use explicit factoriesPlatform transport URLs are injected; provider SDKs still need the setup documented in AI Gateway or provider-owned keys
Cloud transport URLsProfile overrides such as AGENTUITY_TRANSPORT_URL or AGENTUITY_CATALYST_URL can be passed through from the active CLI profileInjected by the platform per region
Public URLOptional Gravity URL through --public or devmode.publicVanity URL, deployment URL, optional custom domain
Hot reloadYours, via the framework's dev serverNone. Each deploy is a new build.

Next Steps