How to call an AI model from an API — in 60 seconds

Want to plug AI into your app, script, or workflow? Calling a model from an API is way easier than it sounds.
Here’s the simple flow:
  • 1. Get an API key: Sign up with your AI provider (like OpenAI or Azure OpenAI), then grab your secret API key from the portal.
  • 2. Find the endpoint: Look for something like /chat/completions or /responses in the docs—this is the URL your app will call.
  • 3. Send a POST request: Use curl, Postman, or your favorite language (Python, JavaScript, C#) to send JSON with your model name and prompt.
  • 4. Include your key securely: Put the API key in an Authorization header (never hard-code it in public code or front-end apps).
  • 5. Parse the response: Read the JSON result, grab the generated text/content field, and plug it back into your app.
Example: A simple POST with { "model": "gpt-4", "input": "Summarize this text..." } returns a JSON object that includes your summary string.
Bottom line: Call URL → send JSON → read JSON. That’s the core pattern behind almost every AI-powered app.

Comments

Popular posts from this blog

How I Reworked My Agents To Stop AI Slop

How I Finally Got AI to Think the Way I Do

How I Cut Repetitive Work in Half Using Tiny Automations