Quick start

Make one Node.js call to recognize “Look up order 000123. Do not cancel the order.” Find the goal and the prohibition without configuring business fields first.

Your taskStart hereModel source
Recognize intent in Node.jsThis exampleYour API or executor
Call it from CodexConnect CodexCurrent model or configured API
Run standalone MCPStandalone serviceService configuration
Extend an MCP serverExisting serverClient model or configured API

1. Install

Use Node.js ≥20 and ESM. Run in your application directory:

npm install @devcodex/intent-runtime

npm installs required dependencies automatically. JavaScript and TypeScript projects use the same API. Set "type": "module" in package.json for .js, or save standalone JavaScript as .mjs. See Installation.

This example recognizes goals and constraints without a business Schema. Add structured parameters later using the order field example.

This path uses your model API credentials. To reuse the current Codex model without an additional key, follow Connect Codex.

2. Configure the model

The example uses the OpenAI Responses API. Set INTENT_API_KEY and INTENT_MODEL to your credentials and an available model name. These are variables read by the application example; the library does not automatically read fixed environment variable names. For xAI or your gateway, see Model APIs.

PowerShell:

$env:INTENT_API_KEY = "your API key"
$env:INTENT_MODEL = "your model name"

Bash:

export INTENT_API_KEY="your API key"
export INTENT_MODEL="your model name"

3. Save and run

Choose your project's language. Save JavaScript as basic.js or TypeScript as basic.ts. Package imports resolve from the file's location.

JavaScript
TypeScript
import {Intent, IntentError} from '@devcodex/intent-runtime';
import {createApiExecutor} from '@devcodex/intent-runtime/adapters/api';

const apiKey = process.env.INTENT_API_KEY;
const model = process.env.INTENT_MODEL;
if (!apiKey || !model) throw new Error('Set INTENT_API_KEY and INTENT_MODEL in your environment.');
const intent = new Intent({
  language: 'en',
  executor: createApiExecutor({provider: 'openai', apiKey, model}),
});
try {
  const result = await intent.parse({input: 'Look up order 000123. Do not cancel the order.'});
  console.log(JSON.stringify(result, null, 2));
  // Read goals and constraints from effective; no order query is executed.
  console.log('Goals:', result.effective.intents.map(node => node.goal));
  console.log('Issues:', result.issues.map(issue => issue.message));
} catch (error) {
  if (!(error instanceof IntentError)) throw error;
  console.error(JSON.stringify(error.toJSON()));
  process.exitCode = 1;
} finally {
  await intent.dispose();
}
node basic.js

4. Read the result

The result should preserve the lookup goal and the prohibition on cancellation. The order ID appears in the natural-language goal. Extracting it into inputs requires a Schema and selecting orderId. Wording and generated IDs can vary.

CheckExpected meaning
GoalLook up order 000123
Constraintprohibition: do not cancel the order
ParametersNo new inputs.orderId because this example selects no fields
IssuesUse actual issues to determine missing information; printing JSON alone does not prove correct understanding

Download the complete no-Schema example or read the Native response with an order field.

  • effective.intents is the goal tree; read global and per-goal constraints.
  • issues describes ambiguity, missing information, and conflicts. Ask for information rather than choosing a candidate yourself.
  • fields defaults to []; omitting it still recognizes intent without new business field extraction.
  • complete does not mean all fields are valid, permission is granted, or business work is done. This program does not query or cancel orders.

Continue with Read the result, or run the field and multi-turn examples. See Model APIs for other providers and Errors when a call fails.