← AI Lab

Call an LLM API From Scratch

September 25, 2026

The Question

  • How do I call an LLM from scratch?

Setup

  • curl, claude api, claude-opus-5-5
curl https://api.anthropic.com/v1/messages \
  -H "content-type: application/json" \
  -H "x-api-key: $ANTHROPIC_API_KEY" \
  -H "anthropic-version: 2023-06-01" \
  -d '{
    "model": "claude-opus-5-5",
    "max_tokens": 1000,
    "messages": [
      {
        "role": "user",
        "content": "What should I search for to find the latest developments in renewable energy?"
      }
    ]
  }'

Results

claude-opus-5-5

{
  "model": "claude-opus-5-5",
  "id": "msg_011CfS5r9N6NN6xyudRKSkXF",
  "type": "message",
  "role": "assistant",
  "content": [
    {
      "type": "thinking",
      "thinking": "",
      "signature": "CAQS/AQKEAgSGAI4AUIIdGhpbmtpbmcSDIZ1/fJGi3Hg/XqGjxoMnqeB7AXtXr8oi6+VIjDPyqbTIZ9VlC2bNIBH/2LcE/4AN5f24lAzoRLOQWyCspWBJv7FagN1tQxBa4fplqMqmQSVtDbxUVAZlwcuDvSN/JGZI33hnTJmrWMgidzXaKsHYDODYDGHlqkde1lz1LzaxzKO+swiQym0QwLQvRlJeHFLDuqmHYN91kL3G8NU7jnds1L0nXU7+wjjLJTOZVMop7q8R0pUguURtYKnWBdRDEMsJ0OZlZaYiY76QTQOoU88I+V3afb6gL1xs5pPwIisTXrIdArbtDP4ot/Kv+hnhTLvgCKdak/6PCsJLSMXrKZbg1OZCjd1BaPV83I2zCbasolh0arBi4a7bIrUuBSc1yfYhvE7feKJ2U2x9KS0Oseab8LGSDEFu6J6fwHcFjnHxDvQwS1qIvFKheYMNnTouMUh+hnFXuVYvfaV4zvb7TVPExt/slZut5reZhMyTzfTyhNBOopDGsYrdPEF6YfAVTCHbjbhVBjm3IZbsiG9uj1v+gskpQE1j1SLva+gj4aC2ZFU7a6YVWScUhb+Tq6FriohRxeEcmgryLq0dW0jGYwP0wyVr4hvA8bVm2ClMiGTO33MVyCQfvLLOtGfJp+4OYgqvk67YRz9ExdlwHL+PTF0EEx1UInoB+saP7DjSSsf6IgVsIIgAyYIKEUxSDjmdWBntZ/EeaSJBg19G6tNOgyvYa4H0ebJdrZmAl5ZVXcxJXfWpuPtnrVayhi3U/ZDUeju46+Gobw+cYsawoQ8XajPxHugxWAUO/X+LIEnYh9luerXfNcG1hxANK0YAQ=="
    },
    {
      "type": "text",
      "text": "Here are some search terms and sources for finding current renewable energy news and research.\n\n## Search Terms\n\n**General:**\n- \"renewable energy news [current month/year]\"\n- \"clean energy breakthroughs\"\n- \"energy transition trends\"\n\n**Specific technologies:**\n- \"perovskite solar cells\" (next-gen solar efficiency)\n- \"offshore wind\" or \"floating wind turbines\"\n- \"green hydrogen\"\n- \"long-duration energy storage\" or \"solid-state batteries\"\n- \"geothermal energy\" (especially \"enhanced geothermal systems\")\n- \"small modular reactors\" (if you're interested in nuclear as low-carbon energy)\n\n**Policy and markets:**\n- \"renewable energy policy [your country]\"\n- \"clean energy investment\"\n- \"grid modernization\" or \"grid interconnection\"\n\n## Reliable Sources\n\n**News:**\n- Canary Media, CleanTechnica, Electrek\n- Bloomberg Green, Reuters Energy\n- Carbon Brief (strong on climate and energy data)\n\n**Data and reports:**\n- International Energy Agency (IEA), with annual reports like *Renewables* and *World Energy Outlook*\n- IRENA (International Renewable Energy Agency)\n- U.S. Energy Information Administration (EIA)\n- National Renewable Energy Laboratory (NREL)\n- BloombergNEF (some content is paywalled)\n\n**Research:**\n- Google Scholar, filtered by recent years\n- Journals like *Nature Energy* and *Joule*\n\n## Search Tips\n- Use Google's **Tools → Time filter** to limit results to the past month or year.\n- Set up **Google Alerts** for topics you want to follow ongoing.\n- Add \"report\" or \"analysis\" to your query for more in-depth content than headlines.\n\nIf you tell me whether you care most about a particular technology, region, or the investment/policy side, I can suggest more targeted searches."
    }
  ],
  "container": null,
  "stop_reason": "end_turn",
  "stop_sequence": null,
  "stop_details": null,
  "usage": {
    "input_tokens": 27,
    "cache_creation_input_tokens": 0,
    "cache_read_input_tokens": 0,
    "cache_creation": {
      "ephemeral_5m_input_tokens": 0,
      "ephemeral_1h_input_tokens": 0
    },
    "output_tokens": 667,
    "output_tokens_details": {
      "thinking_tokens": 31
    },
    "service_tier": "standard",
    "inference_geo": "global"
  },
  "diagnostics": null
}

What I Learned

  • Calling an LLM scratch returns some JSON to work with... As expected.

GIT Repository

  • N/A

Log

  • 2026-09-25 — Starting with something simple.