Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.agentmark.co/llms.txt

Use this file to discover all available pages before exploring further.

The AgentMark client is configured in agentmark.client.ts. It connects your prompts to AI models, tools, evaluations, and prompt loading. This file is auto-generated by npm create agentmark@latest — you can customize it after setup.

Choose your adapter

npm install @agentmark-ai/ai-sdk-v5-adapter @agentmark-ai/loader-api @ai-sdk/openai
agentmark.client.ts
import {
  createAgentMarkClient,
  VercelAIModelRegistry,
} from "@agentmark-ai/ai-sdk-v5-adapter";
import { ApiLoader } from "@agentmark-ai/loader-api";
import { openai } from "@ai-sdk/openai";

const loader =
  process.env.NODE_ENV === "development"
    ? ApiLoader.local({
        baseUrl: process.env.AGENTMARK_BASE_URL || "http://localhost:9418",
      })
    : ApiLoader.cloud({
        apiKey: process.env.AGENTMARK_API_KEY!,
        appId: process.env.AGENTMARK_APP_ID!,
      });

{/* source: oss/agentmark/packages/create-agentmark/src/utils/examples/templates/user-client-config.ts:50-54 */}

const modelRegistry = new VercelAIModelRegistry();
modelRegistry.registerProviders({ openai });
// Or, register individual models:
// modelRegistry.registerModels(["gpt-4o", "gpt-4o-mini"], (name) => openai(name));

export const client = createAgentMarkClient({
  loader,
  modelRegistry,
});
Use with Vercel AI SDK functions: generateText(), generateObject(), streamText(), streamObject().

Model registry

VercelAIModelRegistry supports two registration styles. Providers is the canonical scaffolder pattern — model IDs in prompt frontmatter written as "<provider>/<model>" (e.g. "openai/gpt-4o") auto-resolve:
const modelRegistry = new VercelAIModelRegistry();
modelRegistry.registerProviders({ openai, anthropic });
registerModels(pattern, creator) is the alternative when you need per-model configuration. pattern is string | RegExp | Array<string> — an Array<RegExp> is not a valid overload:
const modelRegistry = new VercelAIModelRegistry();

modelRegistry.registerModels(["gpt-4o", "gpt-4o-mini"], (name) => openai(name));
modelRegistry.registerModels(/^claude-/, (name) => anthropic(name));  // single regex, not wrapped
modelRegistry.registerModels(["dall-e-3"], (name) => openai.image(name));
modelRegistry.registerModels(["tts-1-hd"], (name) => openai.speech(name));
Model names must match the model_name in your prompt frontmatter.

Prompt loading

The loader determines how prompts are fetched at runtime:
// Local — loads from dev server (development)
const loader = ApiLoader.local({
  baseUrl: "http://localhost:9418",
});

// Cloud — loads from the AgentMark HTTP API (production)
const loader = ApiLoader.cloud({
  apiKey: process.env.AGENTMARK_API_KEY!,
  appId: process.env.AGENTMARK_APP_ID!,
});
Prompts are cached in-process in-memory for repeated loads — no extra network round trips for the same path within a process.

Adding tools

Pass tools to the client via the tools option. AI SDK v5 uses inputSchema (v4 used parameters; mixing them fails type-check with TS2769):
import { tool } from "ai";
import { z } from "zod";

export const client = createAgentMarkClient({
  loader,
  modelRegistry,
  tools: {
    calculate: tool({
      description: "Performs arithmetic calculations",
      inputSchema: z.object({
        expression: z.string(),
      }),
      execute: async ({ expression }) => {
        return { result: Function(`"use strict"; return (${expression})`)() };
      },
    }),
  },
});
See Tools and agents for more.

Full reference

For all configuration options including evals, MCP servers, and advanced loader options, see Client config.

Have Questions?

We’re here to help! Choose the best way to reach us: