Skip to content

docs: add FastAPI backend example for non-Node.js setups#540

Merged
vishxrad merged 3 commits into
thesysdev:mainfrom
kevin-weitgenant:examples/fastapi-backend
May 26, 2026
Merged

docs: add FastAPI backend example for non-Node.js setups#540
vishxrad merged 3 commits into
thesysdev:mainfrom
kevin-weitgenant:examples/fastapi-backend

Conversation

@kevin-weitgenant
Copy link
Copy Markdown
Contributor

What

Adds examples/fastapi-backend/ — a minimal chat app using a FastAPI (Python) backend instead of Next.js.

Why

Every example in the repo uses a Node.js runtime (Next.js, SvelteKit, Nuxt). This example demonstrates that OpenUI is backend-agnostic: the same React frontend works with any server that emits the correct stream format.

The frontend (App.jsx) is identical to the one scaffolded by npx @openuidev/cli create — no changes were needed to switch from Next.js to FastAPI.

What's included

  • Backend (~30 lines): FastAPI endpoint that receives { systemPrompt, messages }, calls the OpenAI streaming API, and yields NDJSON chunks
  • Frontend: Vite + React app using openAIReadableStreamAdapter() to parse the stream — same as genui-chat-app
  • README: Setup instructions and architecture diagram matching the style of other examples

Tested

  • Backend streams NDJSON correctly
  • Frontend renders OpenUI Lang components in real time
  • Verified with gpt-5.2 model

Copy link
Copy Markdown
Contributor

@vishxrad vishxrad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor nit. rest LGTM.

@@ -0,0 +1,2 @@
OPENAI_API_KEY=sk-your-key-here
OPENAI_MODEL=gpt-5.2
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please change the model to gpt-5.5. we have a standard model across all examples.

@vishxrad vishxrad merged commit ea0979d into thesysdev:main May 26, 2026
1 check 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