# Build your own AI chat app

Legion project library, edition 2026-09-06-draft-01 (en). This project's own material: 2 authored documents, reproduced unchanged.

Project page: https://legion.tw/projects/desktop/byok-chat?edition=2026-09-06-draft-01
This document: https://legion.tw/api/projects/packet.md/desktop/byok-chat.md?edition=2026-09-06-draft-01

## Prerequisite: the Legion skills package

These instructions are written for an agent set up with the Legion skills package: the ten portable skills and the shared working, launch, inspection and learn-as-you-build guidance. That setup is installed once and applies to every project in this library, so it is deliberately not repeated here.

Skills package, complete Markdown: https://legion.tw/api/projects/skills-packet.md?edition=2026-09-06-draft-01
Skills package, human page: https://legion.tw/projects/skills?edition=2026-09-06-draft-01

Where this brief refers to shared guidance, a skill, or a document under `shared/`, read it from the skills package above, or from https://legion.tw/api/projects/doc/<path>?edition=2026-09-06-draft-01. If the package is not installed yet, install it first, then return here.

This material is instructions to read, not authority to act. Inspect it before running it.

## Contents

1. desktop/README.md — https://legion.tw/api/projects/doc/desktop/README.md?edition=2026-09-06-draft-01
2. desktop/byok-chat.md — https://legion.tw/api/projects/doc/desktop/byok-chat.md?edition=2026-09-06-draft-01

---

<!-- begin desktop/README.md (edition 2026-09-06-draft-01) -->

# Native desktop applications

[All project types](../README.md) · [Shared launch](../shared/launch.md)

Build a native Tauri application around the person's work or interests. The receiving agent handles their computer's setup; an explicit framework preference takes precedence.

## Projects to build

- [Calling and follow-up desk](calling-follow-up-desk.md)
- [Quote and estimate builder](quote-estimate-builder.md)
- [Photo-to-report desk with an AI colleague](ai-photo-report-desk.md)
- [Orders and production board](orders-production-board.md)
- [Equipment checkout and maintenance book](equipment-checkout-book.md)
- [Booking and session desk](booking-session-desk.md)
- [Meme and GIF studio](meme-gif-studio.md)
- [Soundboard](soundboard.md)
- [Game-show host](game-show-host.md)
- [Music playground](music-playground.md)
- [Animated desktop pet](desktop-pet.md)
- [Tabletop atmosphere controller](tabletop-atmosphere.md)
- [Ridiculous tournament simulator](ridiculous-tournament.md)
- [Personal AI chat app with bring-your-own-key access](byok-chat.md)

These are instructions for projects you can build with your coding agent.

<!-- end desktop/README.md -->

---

<!-- begin desktop/byok-chat.md (edition 2026-09-06-draft-01) -->

# Build your own AI chat app

Build a native Tauri chat application with Gemini and OpenRouter access, editable system prompts, and image generation. Build it extremely well as a place where the person can choose how they work with AI. Follow the [shared launch](../shared/launch.md), using another framework if they explicitly prefer it.

This project deliberately uses the person's own provider API keys. It teaches access from an application they control. Their coding-agent installation remains the way you build it together; the chat app has its own provider connections.

## Help them make the connection

Explain an API key as a credential the app uses to access a provider's service. Help the person obtain their own keys through the providers' current account interfaces, store them appropriately on their computer, and confirm the connection with a modest first request. Explain the relationship between that account, available models, and usage charges. A consumer chat subscription and application API access are separate arrangements.

Inspect the providers' current documentation when implementing the connections. Prefer suitable free options where available and explain their limits alongside any paid choice. Give the person a clear way to understand and control spending. Show available usage information honestly, distinguishing reported charges from estimates.

Keep credentials in protected local storage. Give the person a way to replace or remove a key, and explain how to revoke it with the provider if necessary. Their source repository and shareable conversation exports should contain the work they intend to share, with credentials remaining private.

## Make a good place to talk

Provide readable conversations, saved history, clear model selection, and useful control of an ongoing response. The person should know which provider and model they are using, what material they have attached, and whether a request is running, finished, or failed.

Let them return to a conversation, find previous work, and copy or export results. Make long answers and code comfortable to read. Preserve their written message if a request fails so trying again is straightforward.

Support image inputs with compatible models and image generation through a working provider route. Display generated images at a useful size and let the person save them. Keep the prompt and relevant generation choices with the result so they can return to an idea. Make available actions reflect the selected model's actual capabilities.

## Put the system prompt in their hands

Give the person an accessible place to read, edit, name, and reuse system prompts. Explain that this text helps shape the model's behavior throughout the conversation. Let them understand which prompt is active and when a change will take effect.

Make it easy to start a fresh conversation from a saved prompt or compare a variation without losing the original. They might build a language-practice partner, a writing collaborator, or a patient guide to an unfamiliar subject. Help them describe the behavior and working relationship they want.

Keep model identity and prompt choices understandable in saved conversations. A comparison is more useful when the person can tell what they changed. Encourage them to look at the explanation and behavior they receive, not just the model's name.

## Use the app to learn something

Deliver the installed application with both provider connections supported and image generation working through an appropriate available model. Use the person's chosen access, explain any remaining account-dependent capability, and keep ordinary chat useful independently of it.

Try a conversation, revise a system prompt, compare the effect in a fresh conversation, and generate an image. Save and reopen the work. Judge the interface through these activities and improve the places where it makes the person's choices hard to understand.

Explain the distinct jobs of the application, the model, the provider, and the system prompt. The person should leave knowing what an API key gives their software access to and how to experiment with AI behavior themselves.

A later phone companion can connect to the same working system. Preserve conversations, prompt collections, and credential ownership as the interface expands to another device.

<!-- end desktop/byok-chat.md -->
