Skip to content

Conversation

@Sahil5963
Copy link
Contributor

Summary

  • Add runtime.generate() method for clean non-streaming API (similar to Vercel AI SDK's generateText())
  • Add GenerateResult class with toResponse() for CopilotChat-compatible format
  • Update Express demo, NextJS demo, and create-ai-copilot templates

New API

const result = await runtime.generate(body);

// Raw access
result.text         // Generated text
result.messages     // All messages
result.toolCalls    // Tool calls
result.success      // Boolean

// CopilotChat format
result.toResponse() // { success, content, messages, ... }

API Comparison

Mode Raw Format CopilotChat Format
Streaming stream().collect() stream().toResponse()
Non-streaming generate().text generate().toResponse()

Usage Examples

Next.js:

export async function POST(req: Request) {
  const result = await runtime.generate(await req.json());
  return Response.json(result.toResponse());
}

Express:

app.post('/api/chat/generate', async (req, res) => {
  const result = await runtime.generate(req.body);
  res.json(result.toResponse());
});

Test plan

  • Build llm-sdk package
  • Test Express demo /api/chat/generate endpoint
  • Verify CopilotChat-compatible response format

🤖 Generated with Claude Code

Sahil5963 and others added 9 commits January 27, 2026 14:41
…mponents

- Add BackButton compound component (auto-connected to context)
- Add ThreadPicker compound wrapper (auto-connected, renders only with persistence)
- Add ChevronLeftIcon to icons
- ChatView now supports Header/Footer children for view-specific layouts
- Memoize context value to prevent unnecessary re-renders
- Add accessibility props (aria-label, disabled override) to BackButton

Usage:
<CopilotChat.ChatView>
  <CopilotChat.Header>
    <CopilotChat.BackButton />
    <CopilotChat.ThreadPicker />
  </CopilotChat.Header>
</CopilotChat.ChatView>

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add Compound Components section to chat.mdx with examples for
  Root, HomeView, ChatView, Header, Footer, Input, Suggestions,
  BackButton, and ThreadPicker components
- Document view-specific headers pattern
- Add useCopilotChatContext hook documentation
- Add new semantic CSS classes to customizations.mdx

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Expand SDK response formats to include JSON (Non-Streaming) for batch processing and simpler integrations.
- Update documentation with new examples for using `generateText()` and `runtime.chat()` methods.
- Clarify when to use non-streaming responses, including use cases for logging and analytics.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Allows passing custom headers with each request to the runtime endpoint.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add a clean non-streaming API similar to Vercel AI SDK's generateText().

## New API

```typescript
const result = await runtime.generate(body);

// Raw access
result.text         // Generated text
result.messages     // All messages
result.toolCalls    // Tool calls
result.success      // Boolean

// CopilotChat format
result.toResponse() // { success, content, messages, ... }
```

## Changes

- Add `GenerateResult` class with `toResponse()` method
- Add `runtime.generate()` method to Runtime class
- Add `GenerateOptions` type for options (signal, httpRequest, onFinish)
- Update Express demo with `/api/chat/generate` endpoints
- Update NextJS demo with generate route
- Update create-ai-copilot templates with generate examples
- Update documentation

## API Comparison

| Mode | Raw Format | CopilotChat Format |
|------|------------|-------------------|
| Streaming | `stream().collect()` | `stream().toResponse()` |
| Non-streaming | `generate().text` | `generate().toResponse()` |

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@vercel
Copy link

vercel bot commented Jan 27, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
copilot-sdk-docs Ready Ready Preview, Comment Jan 27, 2026 2:35pm

Request Review

@Rohitjoshi9023 Rohitjoshi9023 merged commit c7976ce into main Jan 27, 2026
2 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants