Skip to content
cccskills
Official · VercelFreePublished on GitHub

ai-python-ui-adapter

Use when connecting AI SDK for Python streams to AI SDK UI useChat clients.

The English summary is being prepared. Showing the original description.

See how to install

Files included (1)

  • SKILL.md1.6 KB

SKILL.md (original)

Review the instructions the agent will receive before you install.

ai-python-ui-adapter

Frontend:

const chat = useChat({
  transport: new DefaultChatTransport({ api: "/api/chat" }),
  sendAutomaticallyWhen: lastAssistantMessageIsCompleteWithApprovalResponses,
});

Use chat.sendMessage(...) to send user input. Use chat.addToolApprovalResponse(...) from approval buttons.

Backend request:

class ChatRequest(pydantic.BaseModel):
    messages: list[ai.agents.ui.ai_sdk.UIMessage]

messages, approvals = ai.agents.ui.ai_sdk.to_messages(request.messages)
ai.agents.ui.ai_sdk.apply_approvals(approvals)

Backend stream:

async def body():
    async with agent.run(model, messages) as stream:
        async def events():
            async for event in stream:
                if (
                    isinstance(event, ai.events.HookEvent)
                    and event.hook.status == "pending"
                ):
                    ai.defer_hook(event.hook)
                yield event

        async for chunk in ai.agents.ui.ai_sdk.to_sse(events()):
            yield chunk

return StreamingResponse(
    body(),
    headers=ai.agents.ui.ai_sdk.UI_MESSAGE_STREAM_HEADERS,
)

The adapter handles UIMessage parsing, message IDs, tool state, approvals, subagent MessageBundle values, and AI SDK UI stream events.

You handle the HTTP route, auth, storage, session lookup, frontend rendering, and when to defer hooks.

For saved UI history, use:

ui_messages = ai.agents.ui.ai_sdk.to_ui_messages(messages)

Reviews

No reviews yet. Tell others what you thought.

Comments

No login needed. Share how it worked for you, ask a question, or note where it did not run.

No comments yet. Be the first to write one.

Comments are published right away. Do not include personal information such as email addresses or phone numbers. Up to 2 URLs.

0 / 1,000 characters

This form is protected by reCAPTCHA, and the Google Privacy Policy and Terms of Service apply.

More skills from this repository

ai-python-basics

Official · VercelFree

Use for AI SDK for Python basics. Configure a model, make messages, stream, declare tools, build a basic agent.

The English summary is being prepared. Showing the original description.

vercel-labs/seal8Updated Oct 7, 2026

ai-python-custom-loop

Official · VercelFree

Use when building custom agent loops. Modify tool dispatch, history management, hooks, control flow.

The English summary is being prepared. Showing the original description.

vercel-labs/seal8Updated Oct 7, 2026

ai-python-custom-provider

Official · VercelFree

Use for implementing custom providers in AI SDK for Python.

The English summary is being prepared. Showing the original description.

vercel-labs/seal8Updated Oct 7, 2026

ai-python-durable-execution

Official · VercelFree

Use when adding durable execution to AI SDK for Python, building durable agent loops, or serializing messages across workflow steps.

The English summary is being prepared. Showing the original description.

vercel-labs/seal8Updated Oct 7, 2026

ai-python-serverless-execution

Official · VercelFree

Use when building serverless AI SDK for Python endpoints, handling hook approvals, deferring hooks, or resuming runs across requests.

The English summary is being prepared. Showing the original description.

vercel-labs/seal8Updated Oct 7, 2026

ai-python-streaming-tools

Official · VercelFree

Use for AI SDK for Python async-generator tools, streaming tool output, subagent tools, PartialToolCallResult events, and custom tool aggregation.

The English summary is being prepared. Showing the original description.

vercel-labs/seal8Updated Oct 7, 2026

See all skills by vercel-labs

Report a problem with this skill