Build Your First AI App: Calling an LLM API From Node.js and Python

Going from chat user to AI builder takes about 20 lines of code

Chatting with AI is useful. Building with it is a career skill. In this post we build a tiny app that summarises support tickets using an LLM API. The same pattern works with Anthropic (Claude), OpenAI, Google (Gemini), and others.

Step 1: Get an API Key

  1. Create a developer account with your chosen provider
  2. Generate an API key
  3. Store it in an environment variable — never commit it to Git
export ANTHROPIC_API_KEY="your-key-here"

Step 2: Node.js Version

npm init -y
npm install @anthropic-ai/sdk
// summarise.mjs
import Anthropic from "@anthropic-ai/sdk";

const client = new Anthropic(); // reads ANTHROPIC_API_KEY

const ticket = `Customer reports checkout page loads for 20s since this morning.
Started after the 9am deploy. Affects mobile users mainly.`;

const msg = await client.messages.create({
  model: "claude-sonnet-5-5", // check the provider docs for current model names
  max_tokens: 300,
  system: "You are a support lead. Summarise tickets in 3 bullets: issue, likely cause, next step.",
  messages: [{ role: "user", content: ticket }],
});

console.log(msg.content[0].text);

Run it with node summarise.mjs.

Step 3: Python Version

pip install anthropic
import anthropic

client = anthropic.Anthropic()

msg = client.messages.create(
    model="claude-sonnet-5-5",
    max_tokens=300,
    system="You are a support lead. Summarise tickets in 3 bullets: issue, likely cause, next step.",
    messages=[{"role": "user", "content": "Checkout slow for 20s since 9am deploy, mostly mobile."}],
)
print(msg.content[0].text)

Key Concepts

  • System prompt — the standing instructions for the model's role and rules
  • Messages — the conversation so far (user and assistant turns)
  • max_tokens — upper limit on the response length
  • Model — bigger models are smarter but slower and pricier; small models are great for simple, high-volume tasks

Step 4: Get Structured Output

For apps, you usually want JSON, not prose:

Return only JSON: {"issue": string, "likely_cause": string, "priority": "low"|"medium"|"high"}

Most providers also offer structured output or tool calling features that guarantee valid JSON — use them in production.

Step 5: Stream the Response

For chat UIs, stream tokens as they arrive so users aren't staring at a spinner. Every major SDK has a streaming method.

Step 6: Think About Cost

You pay per input and output token. Tips:

  • Use the smallest model that does the job well
  • Keep prompts concise
  • Use prompt caching for long, repeated instructions or documents
  • Set max_tokens sensibly
  • Log token usage per request (and monitor it, e.g. with New Relic AI Monitoring)

Project Ideas

  • Jira ticket summariser and auto-labeller
  • Resume-vs-job-description gap checker
  • Meeting notes to action items
  • Product description generator from a spreadsheet
  • A chatbot over your own blog using RAG

The jump from user to builder is small. Twenty lines of code, one API key, and you are shipping AI features.

Arivanandhan Chitheshwaran