Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
.DS_Store
package.json
package-lock.json
node_modules/
.idea
.vscode
Expand Down
1 change: 1 addition & 0 deletions .mintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
examples/
4 changes: 4 additions & 0 deletions examples/vercel-ai-telemetry/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
OPENAI_API_KEY=
OPENAI_MODEL=gpt-5
PROMPTLAYER_API_KEY=
OTEL_SERVICE_NAME=vercel-chat-app
42 changes: 42 additions & 0 deletions examples/vercel-ai-telemetry/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.*
.yarn/*
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/versions

# testing
/coverage

# next.js
/.next/
/out/

# production
/build

# misc
.DS_Store
*.pem

# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*
.pnpm-debug.log*

# env files (can opt-in for committing if needed)
.env*
!.env.example

# vercel
.vercel

# typescript
*.tsbuildinfo
next-env.d.ts
68 changes: 68 additions & 0 deletions examples/vercel-ai-telemetry/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# Relay Chat Demo

A simple Next.js App Router scaffold for a chat app built with the Vercel AI SDK and the direct OpenAI provider.

## What is included

- A streaming chat interface powered by `useChat`
- A `ToolLoopAgent` with three mocked server-side tools
- Typed UI messages via `InferAgentUIMessage`
- An API route that streams agent responses with `createAgentUIStreamResponse`

## Setup

1. Install dependencies:

```bash
npm install
```

2. Create a local env file from the example:

```bash
cp .env.example .env.local
```

3. Add your OpenAI API key to `.env.local`:

```bash
OPENAI_API_KEY=your_key_here
```

4. Optional: add PromptLayer tracing credentials if you want OpenTelemetry traces exported to PromptLayer:

```bash
PROMPTLAYER_API_KEY=your_promptlayer_key_here
OTEL_SERVICE_NAME=vercel-chat-app
```

5. Start the app:

```bash
npm run dev
```

Open [http://localhost:3000](http://localhost:3000).

## Model configuration

The scaffold uses the direct OpenAI provider from `@ai-sdk/openai` and defaults to `gpt-5`, matching the current example on the AI SDK OpenAI provider docs. You can override that with:

```bash
OPENAI_MODEL=your_preferred_model
```

## PromptLayer tracing

This app can export Vercel AI SDK traces to PromptLayer using OpenTelemetry.

- `PROMPTLAYER_API_KEY` enables OTLP trace export to PromptLayer
- `OTEL_SERVICE_NAME` optionally overrides the service name shown in traces

If `PROMPTLAYER_API_KEY` is not set, the app still runs normally and skips PromptLayer export.

## Useful scripts

- `npm run dev`
- `npm run lint`
- `npm run typecheck`
20 changes: 20 additions & 0 deletions examples/vercel-ai-telemetry/app/api/chat/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { createAgentUIStreamResponse } from "ai";
import { chatAgent } from "@/lib/chat-agent";

export const maxDuration = 30;

export async function POST(request: Request) {
if (!process.env.OPENAI_API_KEY) {
return new Response(
"Missing OPENAI_API_KEY. Add it to .env.local before using the chat route.",
{ status: 500 },
);
}

const { messages } = await request.json();

return createAgentUIStreamResponse({
agent: chatAgent,
uiMessages: messages,
});
}
Binary file added examples/vercel-ai-telemetry/app/favicon.ico
Binary file not shown.
62 changes: 62 additions & 0 deletions examples/vercel-ai-telemetry/app/globals.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
:root {
--page-background:
radial-gradient(circle at top left, rgba(246, 176, 135, 0.2), transparent 28%),
radial-gradient(circle at bottom right, rgba(45, 156, 139, 0.18), transparent 26%),
#f7f2ea;
--foreground: #15211d;
--muted-foreground: #5e6966;
--panel: rgba(255, 252, 246, 0.84);
--panel-strong: #fffdf8;
--line: rgba(21, 33, 29, 0.08);
--accent: #0f766e;
--accent-strong: #0b5c56;
--accent-soft: rgba(15, 118, 110, 0.12);
--user-bubble: #15211d;
--assistant-bubble: #fff8ef;
--tool-bubble: #f1faf7;
--danger: #a93e2f;
--font-sans: "Avenir Next", "Segoe UI", "Helvetica Neue", Arial, sans-serif;
--font-mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

html {
height: 100%;
}

html,
body {
max-width: 100vw;
overflow-x: hidden;
}

body {
min-height: 100%;
display: flex;
flex-direction: column;
color: var(--foreground);
background: var(--page-background);
font-family: var(--font-sans);
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}

* {
box-sizing: border-box;
padding: 0;
margin: 0;
}

a {
color: inherit;
text-decoration: none;
}

button,
input,
textarea {
font: inherit;
}

::selection {
background: rgba(15, 118, 110, 0.18);
}
19 changes: 19 additions & 0 deletions examples/vercel-ai-telemetry/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import type { Metadata } from "next";
import "./globals.css";

export const metadata: Metadata = {
title: "Relay Chat Demo",
description: "A simple AI SDK chat app with an OpenAI-backed agent and mock tools.",
};

export default function RootLayout({
children,
}: Readonly<{
children: React.ReactNode;
}>) {
return (
<html lang="en">
<body>{children}</body>
</html>
);
}
Loading
Loading