How-to guide

Use chomp as an agent tool

Give any AI agent access to 50+ free models with a single API call.

The pattern

Your orchestrating agent (Claude, GPT-4, etc.) can offload subtasks to free models to save tokens and money. Instead of using its own expensive context for summarization, formatting, or classification, it delegates to chomp.

Shell tool (simplest)

If your agent can run shell commands:

# Dispatch and wait for result
JOB=$(curl -s -X POST https://chomp.coey.dev/api/dispatch \
  -H "Authorization: Bearer $CHOMP_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"prompt": "Summarize this in 3 bullets: ..."}')
JOB_ID=$(echo $JOB | jq -r .id)

# Poll until done
while true; do
  RESULT=$(curl -s https://chomp.coey.dev/api/result/$JOB_ID \
    -H "Authorization: Bearer $CHOMP_TOKEN")
  STATUS=$(echo $RESULT | jq -r .status)
  [ "$STATUS" != "running" ] && break
  sleep 2
done
echo $RESULT | jq -r .result

OpenAI SDK (drop-in)

Point any OpenAI-compatible client at chomp:

from openai import OpenAI

# Point at chomp
client = OpenAI(
    base_url="https://chomp.coey.dev/v1",
    api_key="your-chomp-token",
)

response = client.chat.completions.create(
    model="auto",  # chomp picks the best free model
    messages=[
        {"role": "system", "content": "Summarize in 3 bullet points."},
        {"role": "user", "content": file_contents},
    ],
)
print(response.choices[0].message.content)

TypeScript/JavaScript

Using fetch directly:

const response = await fetch("https://chomp.coey.dev/api/dispatch", {
  method: "POST",
  headers: {
    "Authorization": `Bearer ${process.env.CHOMP_TOKEN}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    prompt: "Classify this text as positive, negative, or neutral: ...",
    system: "Reply with only one word: positive, negative, or neutral.",
  }),
})
const { id } = await response.json()
// Poll /api/result/${id} until status !== "running"

When to use which

  • OpenAI-compatible endpoint (/v1/chat/completions) for synchronous, low-latency calls.
  • Dispatch API (/api/dispatch + /api/result) for async, long-running tasks.
  • MCP tools for Claude Desktop, Cursor, and other MCP clients.