GridNexa
Documentation homeComplete your first model call
GET STARTED / API

Complete your first model call

Call the chat capability with a developer API key and learn how to handle synchronous 200 and asynchronous 202 responses.

Last updated: September 29, 2026Documentation v1
01

Prerequisites

This guide assumes that you can sign in to the Developer Console and unified model invocation is available in the target environment.

  • Create a developer API key beginning with gnx_. The plaintext is shown once.
  • Obtain the API base URL for the target environment.
  • Install curl 8 or another JSON-capable HTTP client.
  • Keep production keys in a secret store or server-side environment variable.
02

Configure environment variables

Store the raw gnx_ key in the environment. The HTTP header format is Authorization: Bearer <key>.

Example
export GRIDNEXA_AI_BASE_URL="https://api.gridnexa.ai"
export GRIDNEXA_AI_API_KEY="gnx_your_key"
DetailsThe example domain is a placeholder. Use the base URL supplied by the console for your environment.
03

Send a chat request

capability is required and determines validation and output shape. When model is omitted, GridNexa selects a published model that supports the capability.

Use a stable Idempotency-Key for requests that may be retried or billed.

Example
curl -X POST "$GRIDNEXA_AI_BASE_URL/v1/invoke" \
  -H "Authorization: Bearer $GRIDNEXA_AI_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: quickstart-chat-001" \
  -d '{
    "capability": "chat",
    "input": {
      "messages": [
        {"role": "user", "content": "Explain GridNexa in one sentence."}
      ]
    },
    "execution": {"mode": "auto"}
  }'
04

Verify the synchronous response

Short chat calls normally return HTTP 200. Verify status=completed and output, and retain meta.requestId for diagnostics. routing.resolved_model identifies the model that ran.

Example
HTTP/1.1 200 OK
{
  "data": {
    "invocation_id": "inv_01J...",
    "status": "completed",
    "capability": "chat",
    "output": {
      "type": "message",
      "message": {"role": "assistant", "content": "..."},
      "finish_reason": "stop"
    },
    "artifacts": [],
    "routing": {"resolved_model": {"name": "...", "version": "..."}}
  },
  "meta": {"requestId": "req_01J..."}
}
05

Handle an asynchronous 202

Video and other long jobs normally return HTTP 202. A 202 means accepted, not completed. Read task_id, status_url, result_url, and retry_after_seconds.

Poll status according to retry_after_seconds, then read the result only after completed.

  • accepted: validated and recorded.
  • queued: waiting for execution capacity.
  • running: currently executing.
  • completed, failed, cancelled, and timed_out are terminal states.
Example
# The 202 response includes status_url and result_url.
curl -H "Authorization: Bearer $GRIDNEXA_AI_API_KEY" \
  "$GRIDNEXA_AI_BASE_URL/v1/tasks/{task_id}"

curl -H "Authorization: Bearer $GRIDNEXA_AI_API_KEY" \
  "$GRIDNEXA_AI_BASE_URL/v1/tasks/{task_id}/result"
06

Use local images or video

Local images and videos use the input-asset upload flow. Create an upload session, PUT the raw file to the presigned URL, complete the upload, and use the ready asset_id in input.

  • POST /v1/input-assets/upload-sessions.
  • PUT the presigned URL. This request uses the URL signature rather than GridNexa Authorization.
  • POST /v1/input-assets/:assetId/complete.
  • Use asset_id in the capability-defined input field.
07

Common failures

Record the HTTP status, platform error code, message, and meta.requestId.

  • 401: verify Bearer plus the raw gnx_ key.
  • 422 CAPABILITY_NOT_SUPPORTED: verify capability, model, and execution mode.
  • 429: honor Retry-After.
  • 410 RESULT_EXPIRED: submit a new task.
Last updated: September 29, 2026
Was this page helpful?
Found a documentation issue?

Choose an issue type, add details, and submit your feedback.