---
title: "Coordinate grounding"
method: POST
path: "/v1/ground"
tags: ["predict"]
---

# Coordinate grounding

`POST /v1/ground`

Find (x, y) for a described UI element using the supplied screenshot. Managed inference has a published 3-credit base and can add only the current-image HD surcharge; trajectory, v1-engine, and prompt surcharges do not apply. BYOK is provider-direct, debits zero Coasty platform credits, and returns actual provider token usage plus non-secret attribution. Ground is a direct CUA primitive: under a test Coasty key, provider-direct BYOK requires an explicit per-request X-LLM-Api-Key plus X-LLM-Provider and can bill that provider account. A body provider without the key header returns 422 LLM_KEY_NOT_CONFIGURED: Stored provider keys are unavailable for test API keys. Send X-LLM-Api-Key explicitly for direct BYOK. Test auth never resolves a stored live provider key. Read effective deployed pricing from GET /v1/models under pricing.

## Headers

- `Idempotency-Key` string
- `X-LLM-Provider` 'anthropic' | 'openai'
- `X-LLM-Api-Key` string
- `X-LLM-Model` string

## Request body

- GroundRequest
  - `screenshot` union, required — One static PNG/JPEG screenshot as raw base64 or an exact data:image/png;base64 / data:image/jpeg;base64 URI. Animated and multi-frame images are rejected. This per-image limit does not multiply the ordinary 15 MiB aggregate JSON request-body cap.
    - string
    - string
    - string
  - `element` string, required — Natural-language description of the UI element.
  - `screen_width` integer, nullable — Omit to use the screenshot's true size (measured server-side); no longer defaults to 1920.
  - `screen_height` integer, nullable — Omit to use the screenshot's true size (measured server-side); no longer defaults to 1080.
  - `llm` LlmConfig — Opt-in BYOK model selection. provider 'managed' (or omitting llm) keeps the platform default. There is deliberately no api_key field (422 if attempted): keys ride the X-LLM-Api-Key header or the encrypted /v1/llm/keys store only. Once BYOK is requested there is NO silent fallback to Coasty's platform LLM keys.
    - `provider` 'managed' | 'anthropic' | 'openai' — Whose LLM account runs the harness. Anything else is 422 LLM_PROVIDER_UNSUPPORTED.
    - `model` string, nullable — Main worker model. Defaults: claude-sonnet-5 (anthropic), gpt-5.6-sol (openai). Model ids are 1-256 characters, begin with a letter or number, and then use only letters, numbers, dot, underscore, colon, slash, plus, at-sign, or hyphen; invalid ids return 422 LLM_MODEL_INVALID. The selected provider can still reject an unknown or inaccessible model. It must be vision-capable.
    - `grounding_model` string, nullable — Override for pixel-coordinate grounding. Defaults to model. Grounding quality is tuned on the platform model; expect best results with the defaults.
    - `compaction_model` string, nullable — Override for trajectory compaction. Defaults to model. A cheaper model here is the classic cost tune.
    - `code_agent_model` string, nullable — Override for the code agent. Defaults to model.

## Response `200`

Grounded coordinates.

- GroundResponse
  - `request_id` string, required
  - `x` integer, required
  - `y` integer, required
  - `screen_width` integer, required — Echo: the width the server actually used — the coordinate space the returned (x, y) are in.
  - `screen_height` integer, required — Echo: the height the server actually used — the coordinate space the returned (x, y) are in.
  - `usage` UsageInfo, required
    - `input_tokens` integer
    - `output_tokens` integer
    - `credits_charged` integer
    - `cost_cents` integer — USD-cent amount; the same numeric value as credits_charged (divide by 100 for USD).
    - `breakdown` object[], nullable — Self-auditable per-call cost breakdown; line credits sum to credits_charged. null on free/test/no-charge calls and /v1/parse.
      - `item` 'base' | 'trajectory' | 'hd_images' | 'engine' | 'custom_prompt', required
      - `credits` integer, required
      - `count` integer, nullable — Optional multiplier (e.g. number of HD screenshots billed); omitted where it adds nothing.
    - `billed` boolean — true on a real Coasty wallet debit; false on BYOK, test keys (sk-coasty-test-*), and idempotent replays (all return credits_charged: 0).
    - `llm_provider` 'managed' | 'anthropic' | 'openai' — Effective inference provider. Non-managed values identify provider-direct BYOK execution.
    - `llm_model` string, nullable — Effective BYOK model id; null for managed inference.
    - `llm_key_fingerprint` string, nullable — Non-secret SHA-256 prefix identifying the BYOK key; never the key itself.
    - `llm_key_source` 'header' | 'stored', nullable — Where the effective BYOK key came from; null for managed inference.
    - `platform_cost_exempt` boolean — true for BYOK. Coasty credits/cost are zero. Provider billing occurs only for provider-direct execution. Managed-mode test Task, Workflow, and schedule sandbox execution makes no provider call; test-auth BYOK intent on those async endpoints is rejected before execution.

## Other responses

- `400` — Invalid request body or parameters.
- `401` — Missing, invalid, or revoked API key. Pass `X-API-Key: sk-coasty-live-...` (or test).
- `402` — Insufficient balance for this operation. Direct metered API calls and managed-machine runtime use the prepaid Developer API wallet; scheduled execution is the documented consumer subscription-credit exception. Follow the operation's billing fields and top up the matching balance in the dashboard.
- `403` — API key lacks the required scope or tier-feature is unavailable on the caller's plan.
- `404` — Resource not found in this key's namespace.
- `409` — The resource state conflicts with this operation.
- `413` — The request body exceeds the endpoint limit.
- `422` — The JSON shape is valid but one or more values violate the endpoint contract.
- `429` — Rate or concurrency limit exceeded.
- `500` — Unexpected server error. Retry with exponential backoff.
- `502` — An upstream dependency returned an invalid response.
- `503` — A required service is temporarily unavailable.
- `504` — An upstream dependency timed out.

---

[API](https://skmtc.net/coasty/apis/coasty-public-api.md) · [All operations](https://skmtc.net/coasty/apis/coasty-public-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/coasty/coasty-public-api/versions/f50d93b0d8a1/schema)
