Building a Chat App with APIs: Intro to the Claude / GPT API

AI Navigate Original / 3/24/2026

💬 OpinionDeveloper Stack & Infrastructure
共有:

Key Points

  • LLM APIs work in ~30 lines after installing each SDK
  • Get keys, set .env, first call for Claude/OpenAI/Vercel AI SDK
  • Multi-turn via messages array; system prompt gives a role
  • Mind key leakage, rate limits, token overflow; cheap to try

LLM APIs Work in "30 Lines of Code"

Want to embed ChatGPT or Claude into your app? The basic use actually works in 30 lines after installing each company's SDK. This article explains the first run, comparing the 2 major APIs—Claude (Anthropic) and GPT (OpenAI)—side by side.

Getting an API Key

OpenAI

  • Go to platform.openai.com → "API keys"
  • Create a new key → shown only once, so copy it
  • Credit deposit needed (from USD 5)

Anthropic

  • console.anthropic.com → "API Keys"
  • Create a new key → likewise shown only once
  • Credit deposit needed (from USD 5)

Environment Setup

# Node.js
npm install @anthropic-ai/sdk openai

# Python
pip install anthropic openai

API keys in .env:

ANTHROPIC_API_KEY=sk-ant-...
OPENAI_API_KEY=sk-...

First Call (Node.js TypeScript)

Claude

Sign up to read the full article

Create a free account to access the full content of our original articles.