https://inference.trygravity.ai/v1
Before you start
- Your Gravity AI platform account is approved.
- Gravity has enabled Inference for your account (ask your Gravity contact if the Inference page is missing in the dashboard).
- You will create a dedicated inference key (
gr_inf_...). Do not reuse your publisher ads API key.
1. Create an inference key
- Open app.trygravity.com/platform/inference.
- Create a key. Copy it once. Gravity stores only a hash.
- Save it as
GRAVITY_INFERENCE_KEYon your server.
2. Models
List models with
GET /v1/models using your inference key. Context window sizes are not claimed in the API.
3. Call chat completions
Use any OpenAI SDK. Pointbase_url at Gravity and pass your inference key.
Every chat request must include a session ID (1 to 256 characters) so Gravity can tie inference to ads in the same session. Send it in any one of:
session_idin the JSON body (preferred)X-Gravity-Session-Idheader- OpenAI
userfield
session_id wins, then the header, then user. A request with none of them returns 400 with code session_id_required and never reaches the model.
Optional:
email_hash: SHA-256 hex of the lowercased, trimmed email (raw emails are rejected). Ties the request to the same person as adshashed_email.- OpenAI
user(1 to 128 characters): also recorded as the end user for rate limits and usage.
Supported features
- Streaming (
stream: true, SSE ending indata: [DONE]) and non-streaming - Tool calling (
tools,tool_choice,parallel_tool_calls, assistanttool_calls,toolmessages) - String or content-part array message content
temperature,top_p,stop,seed,presence_penalty,frequency_penalty,response_format,reasoning_effortdevelopermessages are sent to the provider assystem- Unknown top-level parameters are ignored (not rejected), so standard harness adapters work
- Usage in the stream only when the client sets
stream_options.include_usage
Not supported
n(multiple completions)- Audio
- Browser CORS (use server-side clients)
max_tokens / max_completion_tokens (not both) is optional, 1 to 65,536; omit to use the provider default.
4. Rate limits (pilot)
Limits protect against abuse while you roll out a free tier. You do not need to implement these yourself for Gravity to enforce them.Live today
There is no per-key rate limit today. Keys are protected by hashing, revocation, and account entitlement.
Provider-side rate limits return OpenAI-shaped
429 with code provider_rate_limited. No provider tokens were consumed; retries are safe.
Documented for the pilot (enforcement landing soon)
These are the rational per-user caps for the pilot. Treat them as the contract even if your account does not see them enforced yet. Gravity will enforce them in the API without a change on your side.
Until enforcement ships, you may optionally apply the same caps in your product for a smoother free-tier UX. After enforcement lands, Gravity returns OpenAI-shaped
429 with a clear code (for example end_user_rate_limited or end_user_daily_token_limit).
5. Errors to know
Set
max_retries=0 (or equivalent) on the OpenAI client. Gravity intentionally uses statuses outside the OpenAI SDK’s default retry set for bookkeeping failures so a failed ack does not spend tokens again.
6. Ads and sessions
Inference responses do not embed ads. Request ads separately with the Gravity ads SDK or API, using the samesession_id (and optional hashed email) you send on inference. That is how Gravity attributes free inference to ad revenue for the pilot.
Request ads
Request ads with the same session id you send on inference.
Show ads
Show the ad in your chat UI.
7. Dashboard
On app.trygravity.com/platform/inference you can:- Create and revoke inference keys
- See request volume, errors, tokens, and latency
- Try models in the playground (non-streaming)
Pilot checklist
- Confirm Inference appears in your dashboard.
- Create a key and hit
GET /v1/models. - Send a non-streaming chat with
session_id. - Wire streaming if your product streams.
- Pass a stable per-user id in
user/end_userso per-user limits apply correctly. - Launch your free-tier campaign with the same session ids you use for ads.
- Sync with Gravity after ~5 days of token data to tune limits and models.