llms.txt

Check GPU availability for an 8B model with a $0.99 cap

Estimate the GPU memory an 8B model needs, then look for a single GPU that fits. A $0.99 rental cap keeps the example under one dollar if a matching offer is available.

The last inventory check found no bookable GPU offers. Check live inventory.

Find a GPU that fits

Use fit_model to estimate memory for 16 bit inference with one request and a 2048 token context. Then use search_offers to check price and availability. Memory estimates are not a guarantee for your workload, and a fit result is not a reservation.

Both read calls work without an X9 key. Set X9_API_URL to https://prod-api.x9si.com. These examples use Bash, curl and jq.

Estimate memory and search offers (Bash)
#!/usr/bin/env bash
set -euo pipefail
: "${X9_API_URL:?Set X9_API_URL to your X9 endpoint}"
fit=$(curl -fsS -G "$X9_API_URL/v1/fit" \
  --data-urlencode 'model=8b' --data-urlencode 'task=inference' \
  --data-urlencode 'quant=fp16' --data-urlencode 'ctx=2048' \
  --data-urlencode 'batch=1')
vram=$(jq -er '.vram_need_gb' <<< "$fit")
jq '{vram_need_gb, total_fit}' <<< "$fit"

offers=$(curl -fsS -G "$X9_API_URL/v1/offers" \
  --data-urlencode 'source=x9' --data-urlencode 'gpu_class=consumer' \
  --data-urlencode "min_vram_gb=$vram" --data-urlencode 'max_price_hr=0.99' \
  --data-urlencode 'sort=price')
jq '{next_cursor, matches: [.offers[] | select(.bookable and .gpu_count == 1) | {offer_id,source,upstream,gpu_model,vram_gb,price_hr_all_in}]}' <<< "$offers"

Both examples look for bookable offers for one consumer GPU from an X9 host. They exclude resale offers. If you see no match, do not spend. If the response includes next_cursor, repeat the search with the same filters and set cursor to that value to see the next page.

Sign up as a renter

Use renter signup or call the API. Signup is open while the pilot is open. Set X9_COUNTRY to your actual country code. Signing up accepts the X9 terms.

For a company, set X9_HQ_COUNTRY and X9_PARENT_HQ_COUNTRY for its headquarters and ultimate parent. For each declared Ukrainian location, set the corresponding subdivision variable to an ISO 3166-2 code such as UA-30. Subdivisions for other locations are optional.

Sign up as a renter (Bash)
#!/usr/bin/env bash
set -euo pipefail
: "${X9_API_URL:?Set X9_API_URL to your X9 endpoint}"

: "${X9_COUNTRY:?Set X9_COUNTRY to your two letter country code}"
signup_body=$(jq -nce --arg country "$X9_COUNTRY" --arg invite "${X9_INVITE:-}" \
  --arg country_subdivision "${X9_COUNTRY_SUBDIVISION:-}" \
  --arg hq_country "${X9_HQ_COUNTRY:-}" --arg hq_country_subdivision "${X9_HQ_COUNTRY_SUBDIVISION:-}" \
  --arg parent_hq_country "${X9_PARENT_HQ_COUNTRY:-}" --arg parent_hq_country_subdivision "${X9_PARENT_HQ_COUNTRY_SUBDIVISION:-}" '
  def check_ua($country; $subdivision):
    if ($country | ascii_upcase) == "UA" and ($subdivision | test("^UA-[0-9]{2}$"; "i") | not)
    then error("Use a Ukrainian ISO 3166-2 subdivision code for each declared UA location.")
    else . end;
  {kind:"renter", $country, $country_subdivision, $hq_country, $hq_country_subdivision,
    $parent_hq_country, $parent_hq_country_subdivision, $invite}
  | check_ua($country; $country_subdivision)
  | check_ua($hq_country; $hq_country_subdivision)
  | check_ua($parent_hq_country; $parent_hq_country_subdivision)
  | with_entries(select(.value != ""))')
curl -fsS "$X9_API_URL/v1/accounts" \
  -H 'Content-Type: application/json' -d "$signup_body"

Save the returned api_key as X9_OWNER_KEY in a private shell. It is shown once. Do not give it to your agent.

Create a capped key

With the owner key, create a key with read and spend scopes, a $0.99 lifetime cap, a $0.99 hourly cap, a consumer GPU ceiling and an expiry. Set X9_KEY_REQUEST_ID to a new unique ID and X9_KEY_EXPIRES_AT to a future UTC timestamp. Save both for retries. Give the agent only the returned api_key as X9_API_KEY.

Create a capped renter key (Bash)
#!/usr/bin/env bash
set -euo pipefail
: "${X9_API_URL:?Set X9_API_URL to your X9 endpoint}"

: "${X9_OWNER_KEY:?Set X9_OWNER_KEY in a private shell}"
: "${X9_KEY_REQUEST_ID:?Set and save a unique ID for this key request}"
: "${X9_KEY_EXPIRES_AT:?Set and save a future UTC timestamp}"
key_body=$(jq -nc --arg expires "$X9_KEY_EXPIRES_AT" \
  '{name:"first rental",scopes:["read","spend"],caps:{
    lifetime_usd:"0.99",hourly_usd:"0.99",max_gpu_class:"consumer",expires_at:$expires}}')
curl -fsS "$X9_API_URL/v1/keys" \
  -H "Authorization: Bearer $X9_OWNER_KEY" \
  -H 'Content-Type: application/json' -H "Idempotency-Key: $X9_KEY_REQUEST_ID" \
  -d "$key_body"

On a shared machine, put the bearer header in a mode 600 file and pass -H @file.

This key is sized for one walkthrough. A booking hold counts against the rolling hourly limit even if an early stop costs less.

Read the quote before booking

POST /v1/quotes fields for a capped rental
Quote request fieldWhat to send
offer_idThe ID of the offer you selected.
imageThe container image to run. The sample uses Ubuntu and does not load a model.
max_runtime_sThe maximum runtime in seconds. The sample uses 3600.
max_spend_usdOptional in the API, but set it for any budgeted rental. Use a decimal USD string such as "0.99".
extras_cap_usdRequired for metered resale. Set a positive transfer allowance inside your rental cap, not on top of it. Leave it out for this X9 host example.

Get a matching quote before adding funds. A quote from an X9 host costs nothing and does not need wallet credit. Read price_hr_all_in for hourly compute, worst_case_usd for the most X9 can hold at booking, and expires_in_s for the time left at issuance. Quotes last up to 120 seconds. A price increase on a resold offer can invalidate it sooner. If you get QUOTE_EXPIRED or PRICE_MOVED, get a fresh quote and review it before booking.

Get a quote without booking (Bash)
#!/usr/bin/env bash
set -euo pipefail
: "${X9_API_URL:?Set X9_API_URL to your X9 endpoint}"
: "${X9_API_KEY:?Set X9_API_KEY to the capped renter key}"
K=(-H "Authorization: Bearer $X9_API_KEY")
: "${X9_RUN_ID:?Set and save a unique ID for this rental attempt}"

fit=$(curl -fsS -G "$X9_API_URL/v1/fit" \
  --data-urlencode 'model=8b' --data-urlencode 'task=inference' \
  --data-urlencode 'quant=fp16' --data-urlencode 'ctx=2048' \
  --data-urlencode 'batch=1')
vram=$(jq -er '.vram_need_gb' <<< "$fit")
jq '{vram_need_gb, total_fit}' <<< "$fit"

page=()
while true; do
  offers=$(curl -fsS -G "$X9_API_URL/v1/offers" "${page[@]}" \
    --data-urlencode 'source=x9' --data-urlencode 'gpu_class=consumer' \
    --data-urlencode "min_vram_gb=$vram" --data-urlencode 'max_price_hr=0.99' \
    --data-urlencode 'sort=price')
  offer_id=$(jq -r 'first(.offers[] | select(.bookable and .gpu_count == 1)
    | .offer_id) // ""' <<< "$offers")
  if [[ -n "$offer_id" ]]; then break; fi
  cursor=$(jq -r '.next_cursor // ""' <<< "$offers")
  if [[ -z "$cursor" ]]; then
    echo 'No matching bookable single GPU. No rental was made.' >&2
    exit 1
  fi
  page=(--data-urlencode "cursor=$cursor")
done

quote_body=$(jq -nc --arg id "$offer_id" \
  '{offer_id:$id,image:"ubuntu:24.04",max_runtime_s:3600,max_spend_usd:"0.99"}')
quote=$(curl -fsS "${K[@]}" "$X9_API_URL/v1/quotes" \
  -H 'Content-Type: application/json' -H "Idempotency-Key: $X9_RUN_ID-quote" \
  -d "$quote_body")
jq '{quote_id,price_hr_all_in,worst_case_usd,expires_in_s}' <<< "$quote"
quote_id=$(jq -er 'select((.worst_case_usd | tonumber) <= 0.99) | .quote_id' <<< "$quote")

Use a new X9_RUN_ID for the booking example after funding. The quote above may expire while the payment clears.

Have a person fund the wallet

Add funds only after reviewing a matching quote above and deciding you are ready to book. Use the owner key to request a Stripe Checkout link and save the idempotency key as X9_TOP_UP_IDEM. This adds $5 of wallet credit, not a $5 rental.

Card top ups start at 5 USD. During the 30 day pilot, open money is capped at 100 USD per renter and 500 USD across all renters. Both caps count wallet credit, rental holds and amounts reserved for refunds. Qualifying payments in progress, including unexpired noncard intents and card payments still reserving room, also count. Unfinished live card refunds after account closure, those recorded as failed or cancelled, and amounts set aside for unresolved card disputes count too. The caps are not limits on lifetime deposits. Check your wallet for remaining room.

Card funding (Bash)
#!/usr/bin/env bash
set -euo pipefail
: "${X9_API_URL:?Set X9_API_URL to your X9 endpoint}"

: "${X9_OWNER_KEY:?Set X9_OWNER_KEY in a private shell}"
: "${X9_TOP_UP_IDEM:?Set and save a unique ID for this top up}"
top_up=$(curl -fsS "$X9_API_URL/v1/wallet/top_ups" \
  -H "Authorization: Bearer $X9_OWNER_KEY" \
  -H 'Content-Type: application/json' -H "Idempotency-Key: $X9_TOP_UP_IDEM" \
  -d '{"amount_usd":"5.00","method":"card_link"}')
jq '{checkout_url,top_up_id,expires_at}' <<< "$top_up"

A person opens checkout_url and enters their card in Stripe. Afterwards, keep the same X9_API_URL and set X9_TOP_UP_ID to the returned top_up_id. Wait for confirmed or final before handing work to the agent.

Check payment after Checkout (Bash)
#!/usr/bin/env bash
set -euo pipefail
: "${X9_API_URL:?Set X9_API_URL to your X9 endpoint}"

: "${X9_OWNER_KEY:?Set X9_OWNER_KEY in a private shell}"
: "${X9_TOP_UP_ID:?Set X9_TOP_UP_ID to the returned top_up_id}"
curl -fsS "$X9_API_URL/v1/wallet/top_ups/$X9_TOP_UP_ID" \
  -H "Authorization: Bearer $X9_OWNER_KEY" | jq '{status,final_at}'

Check the balance at GET /v1/wallet. Confirmed card credit can fund a resold rental before the dispute window ends. For metered resale, the quote needs a positive transfer allowance within the rental cap. The runnable example below uses X9 host offers only.

Rent, stop and check the receipt

Set X9_API_URL to the base URL of your X9 API, without a trailing slash. Use the production API at https://prod-api.x9si.com. Run in Bash with curl and jq.

Offer search needs no X9 key. Quote, rent, stop and receipt send Authorization: Bearer with your capped X9_API_KEY. JSON writes send Content-Type: application/json and an Idempotency-Key. Set and save a unique X9_RUN_ID before you start, such as one from uuidgen.

The example estimates model memory before searching. It searches bookable offers from X9 hosts only and follows next_cursor until it finds a match or runs out of pages. For resold GPUs, review the transfer hold in the first rental guide.

This example can automatically book a live rental. Make sure your wallet has enough credit for the hold. It sets a $0.99 cap and requests a stop right away. You may still be charged for billable time before the stop.

Save the run ID and original quote ID. If booking times out, retry only the booking request with the same quote ID, API key and idempotency key. If the stop fails, retry it for the same rental with the original stop key. Confirm the rental ended and any transfer settlement finished before treating the receipt as final.

Find a fit and book a capped rental (Bash)
#!/usr/bin/env bash
set -euo pipefail
: "${X9_API_URL:?Set X9_API_URL to your X9 endpoint}"
: "${X9_API_KEY:?Set X9_API_KEY to the capped renter key}"
K=(-H "Authorization: Bearer $X9_API_KEY")
: "${X9_RUN_ID:?Set and save a unique ID for this rental attempt}"

fit=$(curl -fsS -G "$X9_API_URL/v1/fit" \
  --data-urlencode 'model=8b' --data-urlencode 'task=inference' \
  --data-urlencode 'quant=fp16' --data-urlencode 'ctx=2048' \
  --data-urlencode 'batch=1')
vram=$(jq -er '.vram_need_gb' <<< "$fit")
jq '{vram_need_gb, total_fit}' <<< "$fit"

page=()
while true; do
  offers=$(curl -fsS -G "$X9_API_URL/v1/offers" "${page[@]}" \
    --data-urlencode 'source=x9' --data-urlencode 'gpu_class=consumer' \
    --data-urlencode "min_vram_gb=$vram" --data-urlencode 'max_price_hr=0.99' \
    --data-urlencode 'sort=price')
  offer_id=$(jq -r 'first(.offers[] | select(.bookable and .gpu_count == 1)
    | .offer_id) // ""' <<< "$offers")
  if [[ -n "$offer_id" ]]; then break; fi
  cursor=$(jq -r '.next_cursor // ""' <<< "$offers")
  if [[ -z "$cursor" ]]; then
    echo 'No matching bookable single GPU. No rental was made.' >&2
    exit 1
  fi
  page=(--data-urlencode "cursor=$cursor")
done

quote_body=$(jq -nc --arg id "$offer_id" \
  '{offer_id:$id,image:"ubuntu:24.04",max_runtime_s:3600,max_spend_usd:"0.99"}')
quote=$(curl -fsS "${K[@]}" "$X9_API_URL/v1/quotes" \
  -H 'Content-Type: application/json' -H "Idempotency-Key: $X9_RUN_ID-quote" \
  -d "$quote_body")
jq '{quote_id,price_hr_all_in,worst_case_usd,expires_in_s}' <<< "$quote"
quote_id=$(jq -er 'select((.worst_case_usd | tonumber) <= 0.99) | .quote_id' <<< "$quote")

printf 'Quote ID %s\n' "$quote_id" >&2
rental_body=$(jq -nc --arg id "$quote_id" '{quote_id:$id}')
rental=$(curl -fsS "${K[@]}" "$X9_API_URL/v1/instances" \
  -H 'Content-Type: application/json' -H "Idempotency-Key: $X9_RUN_ID-rent" \
  -d "$rental_body")
resource_id=$(jq -er '.resource_id' <<< "$rental")
printf 'Rental ID %s\n' "$resource_id"

# This example stops right away. Save files before stopping a real workload.
curl -fsS "${K[@]}" "$X9_API_URL/v1/resources/$resource_id/actions" \
  -H 'Content-Type: application/json' -H "Idempotency-Key: $X9_RUN_ID-stop" \
  -d '{"action":"stop"}' | jq '{status,final_cost_usd,settlement_pending}'

# Allow up to a minute here. If settlement takes longer, keep polling this resource.
for (( check=0; check<5; check++ )); do
  resource=$(curl -fsS "${K[@]}" "$X9_API_URL/v1/resources/$resource_id")
  if jq -e '(.status == "stopped" or .status == "failed" or .status == "host_lost"
      or .status == "succeeded" or .status == "cancelled")
      and (.settlement_pending != true)' <<< "$resource" > /dev/null; then
    break
  fi
  if (( check == 4 )); then
    echo "No final receipt yet. Check GET /v1/resources/$resource_id again before reading the final receipt." >&2
    exit 1
  fi
  sleep "$(jq -r '.poll_after_s // 15' <<< "$resource")"
done
curl -fsS "${K[@]}" "$X9_API_URL/v1/receipts/$resource_id" \
  | jq -e 'select(.extras == null or .extras.settled == true)
    | {resource_id,status,price_hr,total_usd,line_items,extras}'

If you want to run work instead of stopping right away, poll GET /v1/resources/{id} using the returned poll_after_s interval. Stop polling if the interval is null. If it never reaches running, check end_reason. Save your results before stopping. The final receipt shows total_usd and billed compute intervals in line_items. If a resale stop says settlement_pending, check the resource again before treating the receipt as final.

Retry the same request safely

Use a different Idempotency-Key for each new top up, key, quote, booking and stop. Keys are 8 to 128 characters. Signup and GET requests do not take this header.

If the network drops before the write answers, retry just that request with the original key, body and API credential. Save them before sending. Do not restart discovery to recover a lost booking reply. Reusing the key with different arguments can return IDEMPOTENCY_CONFLICT. A booking replay may still say booting, so fetch the resource for current status.

A key creation replay returns the key ID, not the secret. If you never received the secret, revoke that key before creating another.

Read Retrying a capped booking for examples of recovering a lost response.