Skip to main content
Week 06 • Track 02 • The Tool

The Integration
Agent.

Stop reading API docs line by line. Paste them into the AI's context and let it build the integration for you—accurately, using the real endpoints.

doc-injection-simulator

> Ready to inject documentation...

> Select a service to begin.

The Mental Model

The Session Musician with Sheet Music.

Without docs, the AI improvises—it guesses endpoints, invents parameters, hallucinates entire APIs. With docs, it plays the exact notes. Every function call is real.

Without docs = Improvisation

The AI guesses based on training data. Endpoints may not exist.

With docs = Sheet music

The AI reads the real API spec. Every call is accurate.

Result = Perfect integration

No hallucinated endpoints. No made-up parameters. Just working code.

Give the AI the sheet music. It will play perfectly.

Without Docs

// AI guesses the API...

const res = await fetch(

'/api/stripe/create-payment'

);

⚠ Endpoint doesn't exist

⚠ Wrong parameter names

⚠ Missing required fields

With Docs

// AI reads the real API spec...

const session = await stripe

.checkout.sessions.create({

line_items: [{ price, quantity }],

mode: 'payment',

success_url: '...',

});

✓ Real endpoint, real params

The Doc Injection Workflow

01

Copy the Docs

Go to the official documentation. Find the specific page for the feature you need. Select the relevant section—not the entire docs site, just the part that matters.

Navigate to the official docs page
Find the specific endpoint or feature
Select and copy the relevant section
stripe.com/docs

// Stripe Checkout Sessions

POST /v1/checkout/sessions

Parameters:

line_items array, required

mode 'payment' | 'subscription'

success_url string, required

cancel_url string

↑ Copy this section

02

Paste into Context

Include the docs in your AI prompt using clear delimiters. The AI needs to know where the documentation starts and ends so it can distinguish your instructions from the reference material.

Use triple backticks or XML tags as delimiters
Label the docs clearly: "Official Stripe API docs"
Keep only what's relevant—trim the noise
ai-prompt

Here is the official documentation

for Stripe Checkout:

```

[PASTED DOCS GO HERE]

```

↑ Clear delimiters

03

Ask Specifically

Tell the AI exactly what to build using those docs. Don't say "integrate Stripe." Say "Build a checkout button that creates a Stripe Checkout Session using the API shown in the docs above."

Name the exact feature you want built
Specify the framework (Next.js, Express, etc.)
Ask for error handling explicitly
ai-prompt (continued)

Based on this documentation, build

a checkout flow that:

1. Creates a Checkout Session

2. Redirects user to Stripe

3. Handles success/cancel URLs

Use Next.js API routes.

Handle errors properly.

↑ Specific instructions

Real-World Examples

S

Stripe

Checkout Session

// Doc snippet you'd paste:

POST /v1/checkout/sessions

line_items: [{ price, qty }]

mode: 'payment'

success_url: string

Your prompt:

"Build a checkout button that creates a Stripe session and redirects the user."

O

OpenAI

Chat Completion

// Doc snippet you'd paste:

POST /v1/chat/completions

model: 'gpt-4o'

messages: [{ role, content }]

temperature: 0-2

Your prompt:

"Build an API route that sends a user message to OpenAI and streams the response."

R

Resend

Transactional Email

// Doc snippet you'd paste:

POST /emails

from: 'you@domain.com'

to: ['user@email.com']

subject, html

Your prompt:

"Build a transactional email sender that sends a welcome email after signup."

The Prompt Template

The Universal Doc Injection Prompt

Use this template every time you need to integrate with an external service. Replace the brackets with your specifics.

doc-injection-template.md

Here is the official documentation for [SERVICE]:

```

[PASTE DOCS HERE]

```

Based on this documentation, build [SPECIFIC FEATURE].

Use [FRAMEWORK / LANGUAGE].

Handle errors properly.

// Optional additions:

Include TypeScript types.

Add environment variable validation.

Follow the project structure I'm using.

Pro tip: The more specific your [SPECIFIC FEATURE] description, the better the output. "Build Stripe integration" is vague. "Build a checkout button that creates a Stripe Checkout Session with a single line item and redirects to a success page" is precise.

Common Patterns

Integration Traps

"Integrate Stripe for me"

No docs provided. The AI guesses endpoints from memory—which may be outdated or wrong.

Hallucinated endpoints

/api/stripe/create-payment doesn't exist. The real endpoint is stripe.checkout.sessions.create().

Pasting the entire docs site

Too much context overwhelms the AI. Paste only the specific section for your feature.

Trusting without verifying

Even with docs, always test the generated code against the real API.

The Clean Integration

Paste the official docs first

Always include the real API reference before asking the AI to build anything.

Be specific about what to build

"Create a POST /api/checkout route using stripe.checkout.sessions.create()" — precise and actionable.

Ask for error handling

Always request try/catch blocks, input validation, and meaningful error responses.

Test against the real API

Use test mode / sandbox keys. Hit the endpoint. Confirm the response matches docs.

The Exercises

Inject docs. Build integrations.

01

The Stripe Injection

Checkout Flow

  • Copy the Stripe Checkout Session docs
  • Paste into AI with the template prompt
  • Ask it to build a checkout button
Goal: Working checkout redirect
02

The OpenAI Injection

Chat Endpoint

  • Copy the OpenAI Chat Completion docs
  • Paste into AI context with delimiters
  • Build a simple chat API endpoint
Goal: Working chat completion route
03

The Email Injection

Transactional Email

  • Copy the Resend API docs for sending emails
  • Paste into AI with clear delimiters
  • Build a transactional email sender
Goal: Working welcome email sender

📋 Quick Reference Cheatsheet

Inject Docs

```[paste docs here]```

Be Specific

"Build [feature] using [framework]"

Always Add

"Handle errors properly."