interlocute.ai beta

API Examples

Copy-paste starter code for interacting with your Interlocute node in cURL, C#, and JavaScript.

Replace my-node with your node's alias from the dashboard. Your node's base URL is https://my-node.interlocute.ai.

cURL: Send a message

curl -X POST https://my-node.interlocute.ai/chat \
  -H "Authorization: Bearer $INTERLOCUTE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "content": "Hello! What can you do?"
  }'

cURL: Continue a thread

curl -X POST https://my-node.interlocute.ai/chat \
  -H "Authorization: Bearer $INTERLOCUTE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "content": "Tell me more about that.",
    "threadId": "thr_abc123"
  }'

cURL: Stream a response

curl -N -X POST https://my-node.interlocute.ai/chat/stream \
  -H "Authorization: Bearer $INTERLOCUTE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "content": "Write a haiku about AI."
  }'
The -N flag disables buffering so you see tokens as they arrive.

cURL: Fetch node info (/chit)

# JSON (default)
curl https://my-node.interlocute.ai/chit/identity

# Plain text
curl -H "Accept: text/plain" https://my-node.interlocute.ai/chit/identity

# Markdown
curl -H "Accept: text/markdown" https://my-node.interlocute.ai/chit/identity

C#: Send a message

using var http = new HttpClient();
http.BaseAddress = new Uri("https://my-node.interlocute.ai/");
http.DefaultRequestHeaders.Authorization =
    new System.Net.Http.Headers.AuthenticationHeaderValue(
        "Bearer", Environment.GetEnvironmentVariable("INTERLOCUTE_API_KEY"));

var response = await http.PostAsJsonAsync(
    "chat",
    new { content = "Hello from C#!" });

response.EnsureSuccessStatusCode();
var result = await response.Content.ReadAsStringAsync();
Console.WriteLine(result);

C#: Continue a thread

var response = await http.PostAsJsonAsync(
    "chat",
    new
    {
        content = "Follow up question...",
        threadId = "thr_abc123"
    });

var result = await response.Content.ReadAsStringAsync();
Console.WriteLine(result);

JavaScript: Send a message

const response = await fetch(
  "https://my-node.interlocute.ai/chat",
  {
    method: "POST",
    headers: {
      "Authorization": `Bearer ${process.env.INTERLOCUTE_API_KEY}`,
      "Content-Type": "application/json",
    },
    body: JSON.stringify({ content: "Hello from JS!" }),
  }
);

const data = await response.json();
console.log(data);

JavaScript: Stream a response

const response = await fetch(
  "https://my-node.interlocute.ai/chat/stream",
  {
    method: "POST",
    headers: {
      "Authorization": `Bearer ${process.env.INTERLOCUTE_API_KEY}`,
      "Content-Type": "application/json",
    },
    body: JSON.stringify({ content: "Stream me a story." }),
  }
);

const reader = response.body.getReader();
const decoder = new TextDecoder();

while (true) {
  const { done, value } = await reader.read();
  if (done) break;
  process.stdout.write(decoder.decode(value));
}

Best practices

  • Timeouts — set a reasonable timeout (30–60 seconds) on your HTTP client. LLM responses can take several seconds for complex queries.
  • Retries — retry on 5xx errors with exponential backoff. Do not retry 4xx errors without fixing the request.
  • Idempotency — include an X-Idempotency-Key header when retrying requests to avoid duplicate processing.
  • Log request IDs — response headers include a request ID. Log it for debugging and support requests.

Next steps