
Get a model via the xAI API
Fetch one model by id so you can confirm pricing, context length, aliases, and reasoning-effort options before you pin that id in production config. Official Models REST reference documents GET /v1/models/{model_id} on https://api.x.ai with a Bearer inference key. The response is a single model object (object: "model") with the same price and capability fields returned on the list route. Create a key and load credits at console.x.ai.
What you need
An XAI_API_KEY, a concrete model_id (for example grok-4.7 or an alias from a prior list call), and a place to store the fields your deploy gate checks. Neighboring jobs include List models via the xAI API when you need the full catalog for this key, Call Grok 4.7 via the API when the check is specifically for that frontier id, and List team models via the xAI Management API when ACL strings must match management names. More API jobs live on the API hub.
Fetch one model
- Export the inference key and set the id you want to inspect:
export XAI_API_KEY="your_api_key"
export MODEL_ID="grok-4.7"
- Request that model and pretty-print the body:
curl "https://api.x.ai/v1/models/${MODEL_ID}" \
-H "Authorization: Bearer $XAI_API_KEY" \
| jq .
Read
id,aliases,owned_by,created(Unix timestamp), andcontext_length. When present, usecapabilities.reasoning_effortto know whichreasoning_effort/reasoning.effortvalues the model accepts, andcapabilities.default_reasoning_effortfor the default when you omit effort. Copy token price fields (prompt_text_token_price,cached_prompt_text_token_price,completion_text_token_price, plus long-context variants andlong_context_thresholdwhen the model has a long-context tier). Image models may returnimage_priceand apricingarray of quality/resolution tiers instead of text token prices.For language models that need modalities or fingerprint, call
GET /v1/language-models/{model_id}from the same reference. Image and video generation have parallel get routes under/v1/image-generation-models/{model_id}and/v1/video-generation-models/{model_id}.
Pitfalls
URL-encoding matters when the id contains characters your shell treats specially — keep the id in a variable and quote the URL. A 404 usually means the key cannot see that model (ACL or retirement), not that the Models API is down. Mixing management-API model name fields with inference id values without checking both surfaces can leave you with an ACL string that never matches what /v1/models/{id} returns for the inference key.