Spacerr
  • Features
  • Pricing
  • FAQ
  • Docs
Get Access
Spacerr
  • Introduction
  • Features
  • Tech Stack
  • Setup
  • Configuration
  • Agents
  • Database
  • Jobs
  • Admin
  • Settings
  • Billing
    • AI Workspace
    • Projects
    • Library
    • Context
    • Models and tools
    • Streams and realtime
  • Storage
  • Email
  • Support
  • Localization
  • SEO
  • Analytics
  • UI And Navigation
  • Deploying To Production
  • Testing And QA
  • Troubleshooting

Search documentation

Search documentation pages.

Documentation/AI Models And Tools

AI Models And Tools

The AI workspace uses the Vercel AI SDK for model calls, streaming, tool calls, message metadata, and generated output. The app keeps model options and tool behavior inside the AI chat feature.

Model Options

Model options live in src/features/ai/chat/constants/chat-model.constants.ts.

txt
export const CHAT_MODEL_OPTIONS = [
  {
    id: "openai/gpt-5.4-nano",
    label: "GPT 5.4 Nano",
    shortLabel: "gpt-5.4-nano",
    provider: "openai",
    providerLabel: "OpenAI",
    descriptionKey: "gptNano",
  },
]

export const DEFAULT_CHAT_MODEL_ID = "openai/gpt-5.4-nano"

The model picker uses this list for labels, provider names, short labels, and descriptions. The request schema also uses the generated model id list to reject unsupported model ids.

Adding A Model

To add a model:

  1. Add the model to CHAT_MODEL_OPTIONS.
  2. Update the translation copy for the model description.
  3. Make sure the model id is available through your Vercel AI Gateway setup.
  4. Test a normal chat request and a regenerated assistant response.

Keep the id value aligned with the provider id expected by the model gateway.

Tool Registry

The tool registry lives in src/features/ai/chat/tools/chat-tools.server.ts.

typescript
export function createChatTools(userId: string, requestOrigin: string, options: CreateChatToolsOptions = {}) {
  return {
    ...createChatSupportTools(userId),
    searchWeb: createChatWebSearchTool(userId, options),
    generateImage: createChatGenerateImageTool(userId, { ...options, requestOrigin }),
  }
}

This is the place to add, remove, or rename model tools. Keep each tool in its own server file so validation, provider calls, and error logging stay focused.

Web Search Tool

Web search lives in src/features/ai/chat/tools/chat-web-search-tool.server.ts.

It uses:

  • perplexity/sonar as the search model.
  • A strict input schema for the query.
  • Structured output with an answer and ordered source cards.
  • Short source descriptions.
  • Bracket citations such as [1] and [2].

The UI renders citations through chat session components, so the assistant can answer with readable source markers while the interface shows source cards.

Image Generation Tool

Image generation lives in src/features/ai/chat/tools/chat-generate-image-tool.server.ts.

It uses:

  • openai/gpt-image-2 as the image model.
  • One image per tool call.
  • 1024x1024 output size.
  • Vercel Blob private storage for generated files.
  • UI rendered image cards instead of raw image URLs in assistant text.

The assistant should not print the image URL after the tool returns. The UI owns the generated image card, download action, and attachment display.

Support And Account Tools

Support and account tools live in src/features/ai/chat/tools/chat-support-tools.server.ts.

The included tools can:

  • Fetch recent support tickets.
  • Create a support ticket when the user explicitly asks for escalation.
  • Read notification preferences.
  • Update notification preferences.

These tools are intentionally scoped to the current authenticated user. Keep account tools narrow and human readable so tool status labels make sense in chat.

Tool Status UI

Tool rendering lives under src/features/ai/chat/components/chat-session.

The important files are:

  • chat-session-tool-status.tsx for deciding how a tool result renders.
  • chat-session-generated-image-tool.tsx for image output cards.
  • chat-session-citations.tsx for cited web sources.
  • chat-session-response-with-citations.tsx for assistant text with source markers.

Tool statuses should use human readable labels. Do not show raw internal tool names as the user facing status.

AI Context

Learn how the assistant context is built and where to customize it.

Streams And Realtime

Learn how chat streaming, stream recovery, stop actions, and realtime sync work.

On this page
Model OptionsAdding A ModelTool RegistryWeb Search ToolImage Generation ToolSupport And Account ToolsTool Status UI