Vibe Coder · Unit 10: APIs · Lesson 4 of 13

Calling OpenAI

The same feature through OpenAI’s API. Keeping the model call in one place makes switching providers a small change.

Read the short notes and pictures.Do everything inside a blue frame.

The same pattern, another provider

Every major model API follows the pattern you just used. Trying a second provider teaches you which parts are universal, and gives you a fallback if one service is down or a different model suits a task better.

A 3D scene of coloured blocks and cards. The same idea: a key, a request, a response.
A key, a request and a response.

Trying it

  1. Add a second key

    In the same environment file, with its own spending limit.

  2. Ask for one function

    "Put the model call behind one function so the provider can be switched."

  3. Run the same inputs

    Compare quality, speed and cost.

  4. Choose a default

    And keep the other as an option.

A 3D scene of coloured blocks and cards. : Call scattered, Call in one place.
One function makes switching a one-file change.
ActivityBuild stepOne AI feature

Make the provider switchable

Ask Claude Code to route the AI feature through one function with a setting for the provider. Run the same three inputs through both and note which you prefer and why.

Done when

Keep the comparison. You will revisit it when costs matter.

Keep these

  • Model APIs share one pattern.
  • Keep the call in one place.
  • Compare providers on your own inputs.