Beta

This API is in beta. Endpoints, request/response formats, and behavior may change without notice.

API Reference

Terramind Documentation

SDK Examples

Get started quickly with these ready-to-use examples. The official SDKs automatically compress request bodies with gzip for optimal performance.

TypeScript SDK

Install
npm install terramind
chat.ts
import { Terramind } from "terramind";

const client = new Terramind({ apiKey: "sk-tm-YOUR_KEY" });

// Non-streaming
const response = await client.chat.create({
  model: "claude-sonnet-4-6",
  messages: [{ role: "user", content: "Hello!" }],
});
console.log(response.content);

// Streaming
const stream = await client.chat.stream({
  model: "claude-sonnet-4-6",
  messages: [{ role: "user", content: "Hello!" }],
});
for await (const chunk of stream) {
  process.stdout.write(chunk);
}

Requests are gzip-compressed by default. To disable: new Terramind({ apiKey: "...", compression: false })

Python SDK

Install
pip install terramind
chat.py
import asyncio
from terramind import Terramind

async def main():
    client = Terramind(api_key="sk-tm-YOUR_KEY")

    # Non-streaming
    response = await client.chat.create(
        model="claude-sonnet-4-6",
        messages=[{"role": "user", "content": "Hello!"}],
    )
    print(response.content)

    # Streaming
    stream = await client.chat.stream(
        model="claude-sonnet-4-6",
        messages=[{"role": "user", "content": "Hello!"}],
    )
    async for chunk in stream:
        print(chunk, end="", flush=True)

    await client.close()

asyncio.run(main())

Requests are gzip-compressed by default. To disable: Terramind(api_key="...", compression=False)

TypeScript (Vercel AI SDK)

app/page.tsx
import { useChat } from "@ai-sdk/react";

export default function Chat() {
  const { messages, input, handleInputChange, handleSubmit } = useChat({
    api: "https://terramind.com/api/v1/chat",
    headers: {
      Authorization: "Bearer sk-tm-YOUR_KEY",
    },
    body: {
      model: "claude-sonnet-4-6",
      system: "You are a helpful assistant.",
    },
  });

  return (
    <div>
      {messages.map((m) => (
        <div key={m.id}>{m.role}: {m.content}</div>
      ))}
      <form onSubmit={handleSubmit}>
        <input value={input} onChange={handleInputChange} />
      </form>
    </div>
  );
}

Node.js (Server-side)

chat.ts
import { streamText } from "ai";
import { createOpenAI } from "@ai-sdk/openai";

const terramind = createOpenAI({
  baseURL: "https://terramind.com/api/v1",
  apiKey: "sk-tm-YOUR_KEY",
});

const result = streamText({
  model: terramind("claude-sonnet-4-6"),
  messages: [{ role: "user", content: "Hello!" }],
});

for await (const chunk of result.textStream) {
  process.stdout.write(chunk);
}