Nirmos

Your first AI request

Read the response, continue a conversation, and choose the next capability.

Complete the quickstart to install the SDK, configure provider credentials and initialize a server-side client. Use an accessible model identifier and a key with gateway:execute.

Model names beginning with configured/ are placeholders. Replace them with an accessible provider-qualified identifier from model discovery. The snippets reuse the server client from the quickstart.

Read the response

const completion = await nirmos.gateway.chat.create({
  model: "configured/chat-model",
  messages: [{ role: "user", content: "Explain an AI gateway in two sentences." }],
  maxOutputTokens: 200,
});
const firstChoice = completion.choices[0];
if (!firstChoice) throw new Error("The provider returned no choices");
console.log(completion.outputText, firstChoice.finishReason);
console.log(completion.usage.inputTokens, completion.usage.outputTokens);
console.log(completion.metadata.requestId);

outputText combines returned text choices. Inspect choices when you need individual messages, tool calls or finish reasons. Token counts normalize to zero when omitted upstream; optional request metadata may be absent.

Continue the conversation

import type { ChatMessage } from "@nirmos/sdk";
const messages: ChatMessage[] = [{ role: "user", content: "What is a model route?" }];
const reply = await nirmos.gateway.chat.create({ model: "configured/chat-model", messages });
if (!reply.choices[0]) throw new Error("No reply");
messages.push(reply.choices[0].message);
messages.push({ role: "user", content: "When would I add fallback?" });
const followup = await nirmos.gateway.chat.create({ model: "configured/chat-model", messages });
console.log(followup.outputText);

The application supplies history on every request. The SDK does not create a persistent conversation automatically. Bound history size for your selected model, and avoid replaying partial tool arguments.

Use streaming for live deltas, managed prompts for reusable instructions, or the chatbot recipe for a complete interactive program. Handle errors around both request creation and stream consumption.

On this page