Skip to Content
Docs@shipshit/ai SDKServer Utilities

Server Utilities

createServerAI

Create a server-side AI client for use in API routes and server components.

import { createServerAI } from '@shipshit/ai/server' const ai = createServerAI({ app: 'sdr', apiSecret: process.env.SHIPSHIT_AI_SECRET!, apiUrl: 'https://ai.shipshit.dev', // optional, this is the default })

Methods

ai.index(content)

Index content for cross-app vector search.

await ai.index({ id: 'lead-123', app: 'sdr', contentType: 'lead', text: 'John Doe at Acme Corp - VP of Engineering', userId: 'clerk_user_123', metadata: { company: 'Acme Corp', stage: 'qualified' } })

ai.search(query, options?)

Semantic search across all apps.

const { results } = await ai.search('Acme Corp', { apps: ['sdr', 'inbox', 'cal'], limit: 10, minScore: 0.5 })

ai.emit(event)

Emit an event to the AI context engine.

await ai.emit({ type: 'lead.created', app: 'sdr', data: { leadId: '123', company: 'Acme Corp' }, userId: 'clerk_user_123' })

ai.chat(messages, options?)

Chat completion with cross-app context.

const response = await ai.chat([ { role: 'user', content: 'Prepare me for the Acme meeting' } ], { crossAppContext: true, contextApps: ['sdr', 'inbox', 'cal'] })

createEvent

Helper to create standardized events.

import { createEvent } from '@shipshit/ai/server' const event = createEvent('sdr', 'lead.qualified', { leadId: '123', score: 85 }, 'clerk_user_123')

getAppFromRequest

Extract and validate the app identifier from a request header.

import { getAppFromRequest } from '@shipshit/ai/server' const app = getAppFromRequest(request) // 'sdr' | 'cal' | ... | null
Last updated on