Developer API

Quick Start

Один раз пройдите auth, создайте developer API key, затем вызывайте video и Ricochet endpoints через Authorization: Bearer GRIK_API_KEY.

Device login

  1. 01

    Создайте device code для app, Ricochet client или editor extension.

  2. 02

    Откройте verification URL и подтвердите показанный user code.

  3. 03

    Опрашивайте token endpoint, затем создайте scoped API key.

  4. 04

    Передавайте Authorization: Bearer GRIK_API_KEY в server-side API requests.

Создать API key

Создавайте scoped server-side keys из authenticated Grik account. Raw key показывается только один раз.

Пример
curl -X POST https://grik.io/api/v1/auth/device/code \
  -H "Content-Type: application/json" \
  -d '{
    "client": "ricochet-vscode",
    "scope": "ricochet_code"
  }'

# Approve the user_code in the browser, then poll:
curl -X POST https://grik.io/api/v1/auth/device/token \
  -H "Content-Type: application/json" \
  -d '{"device_code": "DEVICE_CODE"}'

curl https://grik.io/api/v1/users/me \
  -H "Authorization: Bearer ACCESS_TOKEN"

curl -X POST https://grik.io/api/v1/auth/api-keys \
  -H "Authorization: Bearer ACCESS_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Production API",
    "scopes": ["video", "ricochet_code", "social"],
    "mode": "live"
  }'

Первый request

Передавайте API key как bearer token и добавляйте Idempotency-Key на create-style requests.

Пример
curl -X POST https://grik.io/api/v1/generate/video \
  -H "Authorization: Bearer GRIK_API_KEY" \
  -H "Idempotency-Key: video_job_123" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "kling",
    "prompt": "A cinematic product reveal on a black reflective table",
    "aspect_ratio": "16:9",
    "duration": "5s",
    "mode": "standard",
    "sound": "on"
  }'