Skip to main content
Use this guide to call a model that you deployed on Baseten. To call a hosted model without creating a deployment, see Model APIs. Each deployed model has an HTTPS endpoint. To send a request, you need:
  • Model ID: Found in the Baseten dashboard or returned when you deploy.
  • API key: Authenticates your requests.
  • Model input: A JSON body that matches the input expected by your model.
The model ID (and the deployment ID, when you need to target a specific deployment) comes from the model’s page URL in your workspace: Anatomy of the deployment page URL. In app.baseten.co/models/abc123/deployments/def456, abc123 is the model ID and def456 is the deployment ID.
Call your model from server-side code to avoid exposing your Baseten API key. Dedicated deployment endpoints do not currently include CORS response headers, so browsers may block direct calls.

Authentication

The predict endpoint lives on your model’s own subdomain: Anatomy of the model API endpoint. In https://model-abc123.api.baseten.co/environments/production/predict, abc123 is the model ID and production is the environment that serves the request. Include your API key in the Authorization header:
Request
In Python with requests:
predict.py
Baseten also accepts the legacy Authorization: Api-Key <api_key> scheme on every endpoint, so existing scripts continue to work:
Request

Predict API endpoints

Baseten provides two predict endpoints: Both endpoints can target an environment or a specific deployment. See the inference API overview for URL formats and behavior.

Sync API endpoints

Custom servers also provide a sync endpoint that forwards requests to routes exposed by your server:
URL
These examples show how the sync endpoint maps to the custom server’s routes:
  • https://model-{model_id}.../sync/health -> /health
  • https://model-{model_id}.../sync/items -> /items
  • https://model-{model_id}.../sync/items/123 -> /items/123

OpenAI SDK

Engine-Builder deployments expose an OpenAI-compatible server. To use an OpenAI SDK, set its base URL to your Baseten deployment and authenticate with your Baseten API key:
openai_client.py

External LLM gateways

OpenAI-compatible LLM gateways, such as LiteLLM or OpenRouter, can route traffic to a Baseten deployment. Configure the gateway with three values:
  • Base URL: https://model-{model_id}.api.baseten.co/environments/production/sync/v1, using the model ID for your deployment. Choose API endpoint on the model page in the Baseten dashboard to copy the full URL.
  • Model name: The value of --served-model-name from your deployment’s start_command. See the vLLM example for where this is set. When a single gateway routes to several deployments, use an org/model naming convention (for example, acme/llama-3-70b) to keep routing unambiguous.
  • API key: A Baseten API key with access to the deployment.
The gateway sends requests to {base_url}/chat/completions with model set to the served model name and an Authorization: Bearer <key> header.

Alternative invocation methods