Skip to main content
Run an LLM completion. The router picks the best LLM provider for your intent and fails over automatically.
const { text, provider } = await speko.complete({
  messages: [{ role: 'user', content: 'Hi!' }],
  intent: { language: 'en', vertical: 'general' },
});

Signature

speko.complete(
  params: CompleteParams,
  abortSignal?: AbortSignal,
): Promise<CompleteResult>

Parameters

params: CompleteParams

FieldTypeDescription
messagesChatMessage[]Conversation history. Roles: system, user, assistant.
intentRoutingIntentlanguage, vertical, optional optimizeFor.
systemPromptstring?Shortcut for a leading system message. Providers that distinguish the system channel use it natively; others fold it into the message list.
temperaturenumber?Forwarded to the provider. Defaults to the provider’s default.
maxTokensnumber?Max completion tokens. Defaults to the provider’s default.
constraintsPipelineConstraints?Allow-list constraints.

ChatMessage

interface ChatMessage {
  role: 'system' | 'user' | 'assistant';
  content: string;
}

abortSignal?: AbortSignal

Cancel an in-flight request.

Returns

CompleteResult

FieldTypeDescription
textstringAssistant reply.
providerstringUpstream LLM provider (e.g. openai, anthropic, groq).
modelstringProvider-specific model id.
usage.promptTokensnumberPrompt token count.
usage.completionTokensnumberCompletion token count.
failoverCountnumberProviders tried before this one succeeded.
scoresRunIdstring | nullScoring run id that selected this provider.

Non-streaming (v1)

The /v1/complete endpoint is buffered — each call returns one full completion. Streaming is on the roadmap; until then, tools / function calling are also not exposed through the proxy.

Example: multi-turn

const messages: ChatMessage[] = [
  { role: 'system', content: 'You are a concise voice assistant.' },
  { role: 'user',   content: 'Book me an appointment for Tuesday.' },
];

const first = await speko.complete({
  messages,
  intent: { language: 'en', vertical: 'healthcare' },
  temperature: 0.3,
  maxTokens: 200,
});

messages.push({ role: 'assistant', content: first.text });
messages.push({ role: 'user',      content: '3pm, with Dr. Chen.' });

const second = await speko.complete({
  messages,
  intent: { language: 'en', vertical: 'healthcare' },
});

Example: pin a provider

await speko.complete({
  messages: [...],
  intent: { language: 'en', vertical: 'finance' },
  constraints: { allowedProviders: { llm: ['anthropic'] } },
});