Skip to content

Example: "streamObject" from "ai" in Hono? #3625

Answered by EdamAme-x
hugocxl asked this question in Q&A
Discussion options

You must be logged in to vote

I think just returning it as normal to use c.body seems to work.

app.get("/ai", () => {
  const result = await streamObject({
    schema: vacationSchema,
    output: "array",
    model: openai("gpt-4o-mini"),
    prompt: "Generate 3 vacation destinations",
  });

  return result.toTextStreamResponse();
})

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@wottpal
Comment options

@EdamAme-x
Comment options

@hugocxl
Comment options

@wottpal
Comment options

Answer selected by hugocxl
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants