61 lines
1.6 KiB
Markdown
61 lines
1.6 KiB
Markdown
<div align="center">
|
|
<img width="1200" height="475" alt="GHBanner" src="https://github.com/user-attachments/assets/0aa67016-6eaf-458a-adb2-6e31a0763ed6" />
|
|
</div>
|
|
|
|
# Run and deploy your AI Studio app
|
|
|
|
This contains everything you need to run your app locally.
|
|
|
|
View your app in AI Studio: https://ai.studio/apps/96002e3b-5eec-4566-85e8-718714e15c2c
|
|
|
|
## Run Locally
|
|
|
|
**Prerequisites:** Node.js
|
|
|
|
|
|
1. Install dependencies:
|
|
`npm install`
|
|
2. Set the `GEMINI_API_KEY` in [.env.local](.env.local) to your Gemini API key
|
|
3. Run the app:
|
|
`npm run dev`
|
|
|
|
## Run the API server
|
|
|
|
The UI runs on port `3000`. The HTTP API runs separately on port `3002`.
|
|
|
|
1. Set `GEMINI_API_KEY` in `.env.local` or your shell.
|
|
2. Start the API:
|
|
`npm run api`
|
|
3. Check the API:
|
|
`http://localhost:3002/api/health`
|
|
|
|
### API examples
|
|
|
|
Generate or edit with JSON/base64:
|
|
|
|
```bash
|
|
curl -X POST http://localhost:3002/api/generate \
|
|
-H "Content-Type: application/json" \
|
|
-d "{\"prompt\":\"Create a clean product poster for a white coffee mug\",\"imageSize\":\"1K\",\"aspectRatio\":\"1:1\"}"
|
|
```
|
|
|
|
Upload an image or document with a prompt:
|
|
|
|
```bash
|
|
curl -X POST http://localhost:3002/api/generate/upload \
|
|
-F "prompt=Change the background to a bright studio scene" \
|
|
-F "imageSize=1K" \
|
|
-F "aspectRatio=1:1" \
|
|
-F "files=@input.png"
|
|
```
|
|
|
|
Analyze a document:
|
|
|
|
```bash
|
|
curl -X POST http://localhost:3002/api/analyze-document \
|
|
-F "prompt=Summarize this document in Chinese" \
|
|
-F "files=@report.pdf"
|
|
```
|
|
|
|
Optional API auth: set `API_AUTH_TOKEN`, then send either `Authorization: Bearer <token>` or `x-api-key: <token>`.
|