Skip to content

For Fastapi example, please consider have a server-side NextJs API #4658

Open
@BlakeQG

Description

@BlakeQG

Feature Description

For useChat, if we need to pass the Authorization: Bearer ${token} to it, given we should not have auth code on the client side, I presume (1) either have useChat on the server side; or (2) have a customized API like /api/custom-chat on the vercel servide, that API invokes the fastapi API /fastapi/custom-chat .

But I don't see any example nor discussion about it. Please illustrate.

 useChat({
    api: chatEndpoint,
    headers: {
      "Content-Type": "application/json",
      Authorization: `Bearer ${token}`,
    },
...

https://github.com/vercel/ai/blob/main/examples/next-fastapi/app/(examples)/01-chat-text/page.tsx

Use Cases

No response

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    docsImprovements or additions to documentationenhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions