Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
274 changes: 73 additions & 201 deletions vertexapis-research/CHEATSHEET.md
Original file line number Diff line number Diff line change
@@ -1,243 +1,115 @@
# Vertex Generator - Quick Reference Cheat Sheet
# VertexAPIs Research Cheat Sheet

## Setup (One Time)
This file only references helpers that are actually present in this repo snapshot.

```bash
# Install dependencies
pip3 install requests

# Set API key
export VERTEX_API_KEY="sk-your-api-key-here"

# Or add to ~/.bashrc for persistence
echo 'export VERTEX_API_KEY="sk-your-key"' >> ~/.bashrc
source ~/.bashrc
```

## Quick Commands

### Images (Fast - 5-15 seconds)

```bash
# Simplest - Gemini API
python3 vertex_generator.py image "your prompt here"

# Beta Fast (Flash model)
python3 vertex_generator.py image "your prompt" --api beta

# Beta Quality (Pro model)
python3 vertex_generator.py image "your prompt" --api beta --model pro

# With aspect ratio
python3 vertex_generator.py image "your prompt" --api beta --aspect-ratio 16:9
```

### Videos (Slow - 30-120 seconds)
## Setup

```bash
# Basic video
python3 vertex_generator.py video "your prompt"

# Short video (5 seconds)
python3 vertex_generator.py video "your prompt" --duration 5

# With audio
python3 vertex_generator.py video "your prompt" --audio

# Fast test (720p)
python3 vertex_generator.py video "your prompt" --resolution 720p --duration 5
export VERTEX_API_KEY="sk-your-api-key-here"
```

## Common Use Cases
Run the commands below from the repository root. The committed helper lives at `vertexapis-research/aiplatform_runner.py`.

### Social Media Images
`vertexapis-research/aiplatform_runner.py` reads `VERTEX_API_KEY` by default.

```bash
# Instagram post (1:1)
python3 vertex_generator.py image "product photo" --api beta --aspect-ratio 1:1

# Instagram story (9:16)
python3 vertex_generator.py image "portrait" --api beta --aspect-ratio 9:16
## Provider Notes

# YouTube thumbnail (16:9)
python3 vertex_generator.py image "thumbnail design" --api beta --aspect-ratio 16:9

# Twitter header (21:9)
python3 vertex_generator.py image "banner design" --api beta --aspect-ratio 21:9
```
- `aiplatform.vertexapis.com` is the main repo-contained path for text, image, STT, and try-on examples.
- `beta.vertexapis.com` is still the higher-volume image provider in the research notes.
- `gemini.vertexapis.com` is still mentioned in older notes for image/video workflows, but the generator helper that used it is not committed in this snapshot.

### Video Content
## Quick Commands

```bash
# Short clip for social (5s)
python3 vertex_generator.py video "dynamic intro" --duration 5 --audio

# B-roll footage (8s)
python3 vertex_generator.py video "nature scene" --duration 8 --resolution 1080p

# Quick test (720p, 3s)
python3 vertex_generator.py video "test animation" --duration 3 --resolution 720p
# List registered models
python3 vertexapis-research/aiplatform_runner.py list-models

# Text
python3 vertexapis-research/aiplatform_runner.py text \
--model gemini-3-pro-preview \
--prompt "Kisa bir merhaba yaz"

# Gemini image generation
python3 vertexapis-research/aiplatform_runner.py image \
--model gemini-3.1-flash-image-preview \
--prompt "Single red apple icon on white background" \
--aspect-ratio 1:1

# Imagen predict endpoint
python3 vertexapis-research/aiplatform_runner.py predict-image \
--model imagen-4.0-generate-001 \
--prompt "Single red apple icon on white background"

# STT
python3 vertexapis-research/aiplatform_runner.py stt \
--model gemini-2.5-pro \
--audio ./sample.mp3

# Virtual try-on
python3 vertexapis-research/aiplatform_runner.py try-on \
--person ./person.png \
--product ./product.png
```

## API Selection Guide

| Need | Use This Command |
|------|------------------|
| Quick image test | `--api gemini` |
| High quality image | `--api beta --model pro` |
| Fast image batch | `--api beta --model flash` |
| Any video | `--api gemini` (only option) |

## Rate Limits

```
These limits come from the existing research notes in this repo:

```text
gemini.vertexapis.com: 50/hour, 500/day (image + video)
beta.vertexapis.com: N/A, 3500/day (image only)
```

**Tips:**
- Use Beta for high-volume images (3500/day)
- Use Gemini for videos (only option, 500/day)
- Space requests by 2-5 seconds

## Output Location

```bash
# All files saved to:
~/vertex_outputs/

# List generated files:
ls -lth ~/vertex_outputs/

# Open latest image:
xdg-open ~/vertex_outputs/$(ls -t ~/vertex_outputs/*.png | head -1)

# Open latest video:
mpv ~/vertex_outputs/$(ls -t ~/vertex_outputs/*.mp4 | head -1)
```

## Troubleshooting One-Liners
Default output directory:

```bash
# Check if API key is set
echo $VERTEX_API_KEY

# Test network connectivity
curl -I https://gemini.vertexapis.com/health

# Check rate limit status (gemini only)
curl -H "Authorization: Bearer $VERTEX_API_KEY" \
https://gemini.vertexapis.com/key/status

# View recent errors
python3 vertex_generator.py image "test" --api gemini 2>&1 | grep -i error

# Check Python version
python3 --version

# Verify requests module
python3 -c "import requests; print(requests.__version__)"
~/awesome-cortexai/generated
```

## Batch Generation
Override it with:

```bash
# Generate multiple images
for prompt in "cat" "dog" "bird"; do
python3 vertex_generator.py image "$prompt in space" --api beta
sleep 2
done

# From file
while read prompt; do
python3 vertex_generator.py image "$prompt" --api beta
sleep 3
done < prompts.txt
python3 vertexapis-research/aiplatform_runner.py image \
--model gemini-3.1-flash-image-preview \
--prompt "Single red apple icon on white background" \
--aspect-ratio 1:1 \
--out-dir /tmp/vertex-out
```

## Integration (Python)
## Translate Notes

```python
from vertex_generator import VertexGenerator
import os
Live and documented behavior to remember:

gen = VertexGenerator(os.getenv("VERTEX_API_KEY"))

# Generate image
img = gen.generate_image_gemini("a cat")

# Generate video
vid = gen.generate_video_gemini("ocean waves", duration_seconds=5)
```
- `/language/translate/v2` works
- `/language/translate/v2/detect` works
- `/language/translate/v2/languages` works
- plain `/v2`, `/v2/detect`, `/v2/languages` return `404`
- `v3` and `v3beta1` translation paths work

## Performance Tips

1. **Testing:** Use `--api beta --model flash` (fastest)
2. **Production:** Use `--api beta --model pro` (best quality)
3. **Videos:** Use `--resolution 720p --duration 5` for testing
4. **Rate limits:** Beta API has 7x higher limit than Gemini

## Common Errors & Fixes

| Error | Fix |
|-------|-----|
| "No API key" | `export VERTEX_API_KEY="sk-..."` |
| "Video only supported on gemini" | Add `--api gemini` |
| Rate limit | Wait or use different API |
| Timeout | Video takes 30-120s, be patient |

## Aliases (Optional)

Add to `~/.bashrc`:
## Troubleshooting

```bash
# Quick aliases
alias vimg='python3 ~/awesome-cortexai/vertexapis-research/vertex_generator.py image'
alias vvid='python3 ~/awesome-cortexai/vertexapis-research/vertex_generator.py video'
alias vout='cd ~/vertex_outputs && ls -lth'

# Usage after sourcing bashrc:
# vimg "a cat in space"
# vvid "ocean waves" --duration 5
# vout
```
# Check key
echo "$VERTEX_API_KEY"

## Quick Test
# Show runner help
python3 vertexapis-research/aiplatform_runner.py --help

Run all tests:
```bash
cd ~/awesome-cortexai/vertexapis-research
./test_generator.sh
# Show model registry
python3 vertexapis-research/aiplatform_runner.py list-models
```

## File Size Estimates
## Repo-Contained References

| Type | Resolution | Duration | Size |
|------|------------|----------|------|
| Image (PNG) | N/A | N/A | 1-5 MB |
| Video (720p) | 720p | 5s | 2-5 MB |
| Video (1080p) | 1080p | 5s | 5-10 MB |
| Video (1080p) | 1080p | 10s | 10-20 MB |

## Pro Tips

1. **Always test with 720p first** for videos
2. **Use Beta Flash for rapid iteration** on images
3. **Use Beta Pro for final images** when quality matters
4. **Add --seed** for reproducible results
5. **Space requests 2-5 seconds** to respect rate limits
6. **Check output folder** after generation: `~/vertex_outputs/`

## Getting Help

```bash
# Full help
python3 vertex_generator.py --help

# Examples
python3 vertex_generator.py --help | grep -A 20 Examples
```
- `QUICK_START.md`
- `aiplatform_runner.py`
- `AIPLATFORM_RUNNER_TEST_RESULTS.md`
- `VERTEXAPIS_FINDINGS_2026-02-28.md`
- `endpoints/translate-vertexapis-com.md`

---
## Notes

**Need more info?** Check `GENERATOR_README.md` for complete documentation.
- This repo snapshot does not include a committed video generator helper.
- For TTS/STT curl examples, use `../vertexapis_research/komutlar.md` and `../vertexapis_research/stt.sh`.
Loading