Cloudflare API Gateway example

Open
#21 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 2 days

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
35/100
Issue type
Documentation
Clarity
Needs clarification
Activity status
Stale
Tech stack
typescript
Domain
api, backend

Research direction

Start with the dashboard app's shown TypeScript POST handler and its use of the ai library and streamText. Document or add an example for Cloudflare AI Gateway, including whether the existing library must be replaced; done means the integration path and required changes are clear.

Written by the indexing model from the issue text.

Description

Ia there an example showing how to use Cloudflare AI Gateway with the dashboard app? Do we have to replace the 'ai' lib with a something else? Thanks

import { streamText } from "ai";
import { componentList } from "@/lib/catalog";

export const maxDuration = 30;

export async function POST(req: Request) {
  const { prompt, context } = await req.json();

  let fullPrompt = prompt;

  // Add data context
  if (context?.data) {
    fullPrompt += `\n\nAVAILABLE DATA:\n${JSON.stringify(context.data, null, 2)}`;
  }

  const result = streamText({
    model: "anthropic/claude-haiku-4.5",
    system: SYSTEM_PROMPT,
    prompt: fullPrompt,
    temperature: 0.7,
  });

  return result.toTextStreamResponse();
}

Dominant language
TypeScript
Stars
20k
Forks
1.1k
Avg merge
1d 18h
Merged PRs (30d)
25

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from vercel-labs/json-render

All issues in vercel-labs/json-render

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.