NativePort Inference API
The inference API from NativePort — 3 operation(s) for inference.
The inference API from NativePort — 3 operation(s) for inference.
Every API here is available over the APIs.io API and to AI agents over MCP.
One button, every client — Claude, Cursor, VS Code and the rest.
https://apis.io/mcp
find_apisBrowse and filter every API in the catalog.get_api_artifactsOne API's artifacts, grouped by type.get_openapiThe primary OpenAPI for this API.find_similar_apisAPIs that look like this one.apis_io_searchSTART HERE — APIs, providers and tags for one query, each with its total.resolveTurn a domain, URL or GitHub org into the provider it belongs to.find_cohortsEvery scored population of providers in the catalog.curl "https://apis.io/api/v1/apis/nativeport-ai:nativeport-ai-inference-api"
curl "https://apis.io/api/v1/apis?limit=25"
Calls without X-API-Key need no key. Calls with it need a paid plan — get a key.
Free tier, no form to fill in. Signing in shares your email address with us — we store it to create your key and to recognise you if you sign in with another provider. By signing up you are subscribing to the APIs.io and API Evangelist newsletters — you can unsubscribe from any issue. See our Privacy Policy and Terms.
A second provider on the same verified email joins the account you already have.
openapi: 3.2.0
info:
title: Reference Inference API
version: 1.0.0
servers:
- url: https://api.nativeport.ai
description: NativePort production
- url: http://localhost:8787
description: Local development (wrangler dev)
tags:
- name: Inference
paths:
/inference/v1/chat/completions:
post:
operationId: inference_chatCompletions
summary: Run chat inference against any canonical model
description: 'The unified endpoint''s only `POST`. `model` must be a canonical id
(`openai/`, `anthropic/`, `xai/`, `huggingface//[:provider]`) —
there is no default and no fallback if it''s missing or unresolved; routing from a valid
canonical id to a provider and model is deterministic, never inferred or best-guessed. The
request body accepts only the field set every backing provider
can express in common (see `GET /inference/v1/models` → `supported_parameters` for the exact
list) — a field outside it is rejected with `400 unsupported_parameter` before any upstream
call, never silently dropped. Set `stream: true` for Server-Sent Events instead of a single
JSON object; both forms are OpenAI Chat Completions-shaped regardless of which of the four
providers actually served the request, including for Anthropic, whose native Messages
wire shape is fully translated in both directions to produce this contract. A response''s
`model` field is rewritten to the canonical id that served it, and cross-provider `usage` and
`tool_calls` are reported in this same normalized shape either way.'
tags:
- Inference
responses:
'200':
description: 'A normalized OpenAI Chat Completions response — `application/json` for a single
`chat.completion` object, or `text/event-stream` (when the request set `stream: true`) for
incremental `chat.completion.chunk` events terminated by a literal `data: [DONE]` line.
Regardless of which of the four providers served the request, `usage` and `tool_calls`
(or their streaming `delta` equivalents) are reported in this one shape, and `model`
carries the canonical id that served it. Every response — this one included — carries the
diagnostic `x-nativeport-request-id`, `x-nativeport-provider`, and `x-nativeport-model`
headers described on the [Inference API guide](/inference).
'
content:
application/json:
schema:
$ref: '#/components/schemas/InferenceChatCompletion'
'400':
description: 'The unified endpoint''s own request-policy check rejected the call before any of the four
providers were touched — an unresolved or unsupported `model`, a field outside the
common cross-provider set, a structurally invalid message/tool shape, `image_url` content
aimed at a model whose `capabilities.vision` is `false`, or an explicit `max_tokens`/
`max_completion_tokens` above the resolved model''s provider-configured output ceiling — every
one of the four backing providers enforces its own ceiling here, same as on its native route.
Always the OpenAI
`{"error":{message,type,param,code}}` envelope regardless of the resolved provider — see the
[Inference API guide](/inference) for the full `code` list.
'
content:
application/json:
schema:
$ref: '#/components/schemas/InferenceError'
'401':
description: 'The bearer token was missing, unknown, or revoked. The reply body is the JSON `{ "error": "Unauthorized." }`.
'
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'402':
description: "Insufficient credits — either of two distinct checks, at two different layers, can produce\nthis status:\n\n- **The account-wide credit gate**, shared by every route in this spec (see [Common\n responses](/api-reference)), rejects the call before it reaches `/inference` routing logic\n at all if the account balance is zero or negative. This one answers the gateway-wide plain\n `{\"error\": \"...\"}` shape, not the OpenAI-shaped envelope the rest of this endpoint uses.\n- **A per-request cost-estimate preflight**, inside whichever of the four provider pipelines\n the request resolved to, rejects a specific call whose estimated input cost alone would\n exceed the remaining balance. This one uses the OpenAI-shaped envelope, consistent with\n every other error this endpoint produces past the gate — though `code` is always\n `gateway_insufficient_credits`, the envelope's `type` string is whichever that resolved\n provider's own pipeline uses (`insufficient_credits` for OpenAI, `billing_error` for\n Anthropic, `invalid_request_error` for xAI and Hugging Face), not a single normalized value.\n"
content:
application/json:
schema:
$ref: '#/components/schemas/InferenceChatCompletionsRequestPaymentRequiredError'
'403':
description: The bearer token is valid but the account is currently suspended (non-billing enforcement action, distinct from an empty balance).
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'429':
description: 'The per-account rate limiter (shared with the legacy `/openai/v1/*`, `/anthropic/v1/*`,
`/grok/v1/*`, and `/huggingface/v1/*` routes — one capacity pool per provider, not a separate
one for this endpoint) refused the request. Carries a `retry-after` header in seconds. `code`
is always `gateway_rate_limited`; the envelope''s `type` string mirrors whichever provider''s
own pipeline produced it (`rate_limit_error` for OpenAI and Anthropic, `invalid_request_error`
for xAI and Hugging Face) rather than one normalized value — the example below shows the
OpenAI/Anthropic form.
'
content:
application/json:
schema:
$ref: '#/components/schemas/InferenceError'
'502':
description: 'The resolved provider''s own upstream was unreachable (DNS/connection/TLS/timeout) rather than
answering with an error response of its own. Never echoes the underlying connection error, to
avoid leaking upstream infrastructure details.
'
content:
application/json:
schema:
$ref: '#/components/schemas/InferenceError'
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/InferenceChatRequest'
security:
- bearerAuth: []
/inference/v1/models:
get:
operationId: inference_listModels
summary: List every model your key can reach
description: 'Every canonical id across all four providers that this gateway supports — a model it
doesn''t support is simply absent from this list, the same way the four native provider
routes filter their own local `GET /v1/models`. `GET /inference/v1/models` is the
authoritative list of model IDs supported by the gateway. Each entry carries its `capabilities`, the exact
`supported_parameters` this gateway accepts for it, and per-1M-token USD `pricing`.'
tags:
- Inference
responses:
'200':
description: The catalog of models supported by the gateway, OpenAI model-list-shaped.
content:
application/json:
schema:
$ref: '#/components/schemas/InferenceModelList'
'401':
description: 'The bearer token was missing, unknown, or revoked. The reply body is the JSON `{ "error": "Unauthorized." }`.
'
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'402':
description: "Insufficient credits — either of two distinct checks, at two different layers, can produce\nthis status:\n\n- **The account-wide credit gate**, shared by every route in this spec (see [Common\n responses](/api-reference)), rejects the call before it reaches `/inference` routing logic\n at all if the account balance is zero or negative. This one answers the gateway-wide plain\n `{\"error\": \"...\"}` shape, not the OpenAI-shaped envelope the rest of this endpoint uses.\n- **A per-request cost-estimate preflight**, inside whichever of the four provider pipelines\n the request resolved to, rejects a specific call whose estimated input cost alone would\n exceed the remaining balance. This one uses the OpenAI-shaped envelope, consistent with\n every other error this endpoint produces past the gate — though `code` is always\n `gateway_insufficient_credits`, the envelope's `type` string is whichever that resolved\n provider's own pipeline uses (`insufficient_credits` for OpenAI, `billing_error` for\n Anthropic, `invalid_request_error` for xAI and Hugging Face), not a single normalized value.\n"
content:
application/json:
schema:
$ref: '#/components/schemas/InferenceListModelsRequestPaymentRequiredError'
'403':
description: The bearer token is valid but the account is currently suspended (non-billing enforcement action, distinct from an empty balance).
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
security:
- bearerAuth: []
/inference/v1/models/{id}:
get:
operationId: inference_getModel
summary: Look up one canonical model
description: 'Answers with the same object shape as an entry in `GET /inference/v1/models`''s `data` array —
capabilities, `supported_parameters`, and pricing — for exactly one canonical id, filtered by
the same availability rule: an id this gateway doesn''t support answers the identical
`404 model_not_found`.'
tags:
- Inference
parameters:
- name: id
in: path
description: 'The canonical model id to look up. IDs can themselves contain further `/` segments — the
Hugging Face form is `huggingface/<owner>/<model>[:provider]` — so this segment is a
slash-inclusive wildcard capture, the same pattern this spec uses for `{path}` on the
twenty-four transparent wildcard proxies (e.g. `/firecrawl/{path}`), not a single
path-templated token. An id that doesn''t resolve to a model this gateway supports answers
this endpoint''s own `404` rather than the underlying provider''s.
'
required: true
schema:
type: string
responses:
'200':
description: The looked-up model's catalog entry.
content:
application/json:
schema:
$ref: '#/components/schemas/InferenceModel'
'401':
description: 'The bearer token was missing, unknown, or revoked. The reply body is the JSON `{ "error": "Unauthorized." }`.
'
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'402':
description: "Insufficient credits — either of two distinct checks, at two different layers, can produce\nthis status:\n\n- **The account-wide credit gate**, shared by every route in this spec (see [Common\n responses](/api-reference)), rejects the call before it reaches `/inference` routing logic\n at all if the account balance is zero or negative. This one answers the gateway-wide plain\n `{\"error\": \"...\"}` shape, not the OpenAI-shaped envelope the rest of this endpoint uses.\n- **A per-request cost-estimate preflight**, inside whichever of the four provider pipelines\n the request resolved to, rejects a specific call whose estimated input cost alone would\n exceed the remaining balance. This one uses the OpenAI-shaped envelope, consistent with\n every other error this endpoint produces past the gate — though `code` is always\n `gateway_insufficient_credits`, the envelope's `type` string is whichever that resolved\n provider's own pipeline uses (`insufficient_credits` for OpenAI, `billing_error` for\n Anthropic, `invalid_request_error` for xAI and Hugging Face), not a single normalized value.\n"
content:
application/json:
schema:
$ref: '#/components/schemas/InferenceGetModelRequestPaymentRequiredError'
'403':
description: The bearer token is valid but the account is currently suspended (non-billing enforcement action, distinct from an empty balance).
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'404':
description: '`GET /inference/v1/models/{id}` was called with an id that doesn''t resolve to a model this
gateway supports — the same fail-closed shape `PolicyRejected`/`NotFound` share elsewhere in
this spec.
'
content:
application/json:
schema:
$ref: '#/components/schemas/InferenceError'
security:
- bearerAuth: []
components:
schemas:
InferenceModelList:
type: object
properties:
object:
type: string
enum:
- list
data:
type: array
items:
$ref: '#/components/schemas/InferenceModel'
title: InferenceModelList
InferenceImageContentPart:
type: object
properties:
type:
type: string
enum:
- image_url
image_url:
$ref: '#/components/schemas/InferenceImageContentPartImageUrl'
required:
- type
- image_url
title: InferenceImageContentPart
InferenceChatMessage:
type: object
properties:
role:
$ref: '#/components/schemas/InferenceChatMessageRole'
content:
$ref: '#/components/schemas/InferenceChatMessageContent'
description: 'Required for every role except `assistant` when it carries `tool_calls` instead. A plain
string, or an array of `text`/`image_url` parts (see `InferenceContentPart`) — image parts
are validated the same way regardless of role, so vision-capability rejection also applies
to a `tool` message''s image content.
'
tool_calls:
type: array
items:
$ref: '#/components/schemas/InferenceToolCall'
description: Only valid on an `assistant` message.
tool_call_id:
type: string
description: Required on a `tool` message (naming the call this message answers); invalid on any other role.
required:
- role
title: InferenceChatMessage
InferenceChatMessageContent1:
type: array
items:
$ref: '#/components/schemas/InferenceContentPart'
title: InferenceChatMessageContent1
InferenceModelProvider:
type: string
enum:
- openai
- anthropic
- xai
- huggingface
title: InferenceModelProvider
InferenceModelPricing:
type: object
properties:
currency:
type: string
enum:
- usd
input_per_million:
type: number
format: double
output_per_million:
type: number
format: double
cached_input_per_million:
type: number
format: double
description: OpenAI's cached-input discount rate, or Anthropic's cache-READ rate. Absent where the provider has no cache-read discount (xAI, Hugging Face).
cache_write_5m_per_million:
type: number
format: double
description: Anthropic only — writing a 5-minute ephemeral cache breakpoint.
cache_write_1h_per_million:
type: number
format: double
description: Anthropic only — writing a 1-hour ephemeral cache breakpoint.
cache_write_per_million:
type: number
format: double
description: OpenAI `gpt-5.6` family only — rate for the `cache_write_tokens` category OpenAI reports in `usage.input_tokens_details` (Responses API) or `usage.prompt_tokens_details` (Chat Completions API). A mutually exclusive input token category, never additive with `input_per_million` or `cached_input_per_million`.
long_context:
$ref: '#/components/schemas/InferenceModelPricingLongContext'
description: OpenAI `gpt-5.6` family only — present when the model has a distinct rate tier for requests whose input token count exceeds `threshold_input_tokens`. Absent for every other provider and model.
description: Clean per-1M-token USD rates with the gateway's 5.5% fee included, sourced from the same price tables each native provider route bills from.
title: InferenceModelPricing
InferenceToolCall:
type: object
properties:
id:
type: string
type:
type: string
enum:
- function
function:
$ref: '#/components/schemas/InferenceToolCallFunction'
required:
- id
- type
- function
title: InferenceToolCall
InferenceChatRequestStreamOptions:
type: object
properties:
include_usage:
type: boolean
description: Emit one extra usage-only chunk (empty `choices`) immediately before `[DONE]`.
title: InferenceChatRequestStreamOptions
InferenceChatRequest:
type: object
properties:
model:
type: string
description: A canonical model id. Mandatory — there is no default and no fallback. See the [Inference API guide](/inference) for the `openai/<id>` / `anthropic/<id>` / `xai/<id>` / `huggingface/<owner>/<model>[:provider]` forms.
messages:
type: array
items:
$ref: '#/components/schemas/InferenceChatMessage'
max_tokens:
type: integer
minimum: 1
description: For a request resolving to an Anthropic model, mapped to that API's required `max_tokens` field; if neither this nor `max_completion_tokens` is set, the gateway injects Anthropic's configured default rather than letting the call 400 there alone.
max_completion_tokens:
type: integer
minimum: 1
temperature:
type: number
format: double
top_p:
type: number
format: double
stop:
$ref: '#/components/schemas/InferenceChatRequestStop'
stream:
type: boolean
description: Selects the `text/event-stream` response form over a single JSON object.
stream_options:
$ref: '#/components/schemas/InferenceChatRequestStreamOptions'
tools:
type: array
items:
$ref: '#/components/schemas/InferenceToolDefinition'
tool_choice:
$ref: '#/components/schemas/InferenceToolChoice'
parallel_tool_calls:
type: boolean
required:
- model
- messages
description: 'OpenAI Chat Completions-shaped, but deliberately narrower: only the field set every one of the
four backing providers can express in common is accepted (this schema''s own property list —
the same set `GET /inference/v1/models` reports per model as `supported_parameters`). A field
outside it is rejected with `400 unsupported_parameter` before any upstream call.
'
title: InferenceChatRequest
InferenceUsage:
type: object
properties:
prompt_tokens:
type: integer
completion_tokens:
type: integer
total_tokens:
type: integer
prompt_tokens_details:
$ref: '#/components/schemas/InferenceUsagePromptTokensDetails'
description: Present only when the resolved model reports cache-read tokens.
title: InferenceUsage
InferenceModelPricingLongContext:
type: object
properties:
threshold_input_tokens:
type: integer
description: Input token count above which these long-context rates replace the top-level (short-context) rates.
input_per_million:
type: number
format: double
cached_input_per_million:
type: number
format: double
cache_write_per_million:
type: number
format: double
output_per_million:
type: number
format: double
description: OpenAI `gpt-5.6` family only — present when the model has a distinct rate tier for requests whose input token count exceeds `threshold_input_tokens`. Absent for every other provider and model.
title: InferenceModelPricingLongContext
InferenceChatCompletionsRequestPaymentRequiredError:
oneOf:
- $ref: '#/components/schemas/Error'
- $ref: '#/components/schemas/InferenceError'
title: InferenceChatCompletionsRequestPaymentRequiredError
InferenceChatMessageRole:
type: string
enum:
- system
- user
- assistant
- tool
title: InferenceChatMessageRole
InferenceChatMessageContent:
oneOf:
- type: string
- $ref: '#/components/schemas/InferenceChatMessageContent1'
description: 'Required for every role except `assistant` when it carries `tool_calls` instead. A plain
string, or an array of `text`/`image_url` parts (see `InferenceContentPart`) — image parts
are validated the same way regardless of role, so vision-capability rejection also applies
to a `tool` message''s image content.
'
title: InferenceChatMessageContent
InferenceChatCompletionChoicesItemsMessage:
type: object
properties:
role:
type: string
enum:
- assistant
content:
type:
- string
- 'null'
tool_calls:
type: array
items:
$ref: '#/components/schemas/InferenceToolCall'
title: InferenceChatCompletionChoicesItemsMessage
InferenceChatRequestStop:
oneOf:
- type: string
- type: array
items:
type: string
title: InferenceChatRequestStop
InferenceErrorError:
type: object
properties:
message:
type: string
description: Explanatory message meant for humans.
type:
type: string
description: An error category. The envelope shape is uniform, but for a gateway-originated error this string is whichever vocabulary the resolved provider's own pipeline uses (mostly OpenAI-style values like `invalid_request_error`/`rate_limit_error`, plus provider-specific ones like Anthropic's `billing_error` or OpenAI's own `insufficient_credits`) — it is not normalized to one fixed value across providers.
param:
type:
- string
- 'null'
description: The offending request field, when the error names one.
code:
type:
- string
- 'null'
description: A stable machine-readable reason. A `gateway_*` code is gateway-originated rather than passed through from a provider.
required:
- message
- type
- param
- code
title: InferenceErrorError
InferenceToolChoice0:
type: string
enum:
- auto
- none
- required
title: InferenceToolChoice0
InferenceGetModelRequestPaymentRequiredError:
oneOf:
- $ref: '#/components/schemas/Error'
- $ref: '#/components/schemas/InferenceError'
title: InferenceGetModelRequestPaymentRequiredError
InferenceToolChoice:
oneOf:
- $ref: '#/components/schemas/InferenceToolChoice0'
- $ref: '#/components/schemas/InferenceToolChoice1'
description: '`"auto"`, `"none"`, `"required"`, or an object pinning one specific function tool.'
title: InferenceToolChoice
InferenceListModelsRequestPaymentRequiredError:
oneOf:
- $ref: '#/components/schemas/Error'
- $ref: '#/components/schemas/InferenceError'
title: InferenceListModelsRequestPaymentRequiredError
InferenceChatCompletionChoicesItems:
type: object
properties:
index:
type: integer
message:
$ref: '#/components/schemas/InferenceChatCompletionChoicesItemsMessage'
finish_reason:
$ref: '#/components/schemas/InferenceChatCompletionChoicesItemsFinishReason'
logprobs:
oneOf:
- description: Any type
- type: 'null'
title: InferenceChatCompletionChoicesItems
InferenceToolDefinitionFunction:
type: object
properties:
name:
type: string
pattern: ^[a-zA-Z0-9_-]{1,64}$
description:
type: string
parameters:
type: object
additionalProperties:
description: Any type
description: A JSON Schema object describing the function's arguments. Omitted means the function takes none.
required:
- name
title: InferenceToolDefinitionFunction
InferenceImageContentPartImageUrl:
type: object
properties:
url:
type: string
description: 'A `https://` URL or a `data:` URI. Only honored for a model whose
`GET /inference/v1/models` entry reports `capabilities.vision: true` — sent to any
other model, the whole request is rejected preflight with `400 unsupported_parameter`.
'
required:
- url
title: InferenceImageContentPartImageUrl
InferenceModelCapabilities:
type: object
properties:
streaming:
type: boolean
tools:
type: boolean
tool_choice:
type: boolean
vision:
type: boolean
description: Whether this specific model is known to accept `image_url` content parts — truthful per model, not a blanket value across the catalog.
title: InferenceModelCapabilities
InferenceChatCompletion:
type: object
properties:
id:
type: string
object:
type: string
enum:
- chat.completion
created:
type: integer
model:
type: string
description: Rewritten to the canonical id that actually served the request, regardless of the provider's own native model identifier.
choices:
type: array
items:
$ref: '#/components/schemas/InferenceChatCompletionChoicesItems'
usage:
$ref: '#/components/schemas/InferenceUsage'
title: InferenceChatCompletion
InferenceContentPart:
oneOf:
- $ref: '#/components/schemas/InferenceTextContentPart'
- $ref: '#/components/schemas/InferenceImageContentPart'
title: InferenceContentPart
InferenceChatCompletionChoicesItemsFinishReason:
type: string
enum:
- stop
- length
- tool_calls
- content_filter
title: InferenceChatCompletionChoicesItemsFinishReason
InferenceUsagePromptTokensDetails:
type: object
properties:
cached_tokens:
type: integer
description: Present only when the resolved model reports cache-read tokens.
title: InferenceUsagePromptTokensDetails
InferenceToolCallFunction:
type: object
properties:
name:
type: string
arguments:
type: string
description: A JSON-encoded string of the call's arguments (not a nested object).
required:
- name
- arguments
title: InferenceToolCallFunction
Error:
type: object
properties:
error:
type: string
description: Explanatory message meant for humans.
required:
- error
title: Error
InferenceToolChoice1:
type: object
properties:
type:
type: string
enum:
- function
function:
$ref: '#/components/schemas/InferenceToolChoiceOneOf1Function'
required:
- type
- function
title: InferenceToolChoice1
InferenceTextContentPart:
type: object
properties:
type:
type: string
enum:
- text
text:
type: string
required:
- type
- text
title: InferenceTextContentPart
InferenceToolDefinition:
type: object
properties:
type:
type: string
enum:
- function
function:
$ref: '#/components/schemas/InferenceToolDefinitionFunction'
required:
- type
- function
title: InferenceToolDefinition
InferenceModel:
type: object
properties:
id:
type: string
description: The canonical model id (same form accepted in a chat request's `model` field).
object:
type: string
enum:
- model
created:
type: integer
owned_by:
type: string
description: For a Hugging Face entry, the underlying HF repo's owner segment — not necessarily the same string as `provider`.
provider:
$ref: '#/components/schemas/InferenceModelProvider'
capabilities:
$ref: '#/components/schemas/InferenceModelCapabilities'
supported_parameters:
type: array
items:
type: string
description: The optional `InferenceChatRequest` fields this gateway accepts — uniform across every listed model, since the common set is provider-agnostic by construction.
pricing:
$ref: '#/components/schemas/InferenceModelPricing'
title: InferenceModel
InferenceError:
type: object
properties:
error:
$ref: '#/components/schemas/InferenceErrorError'
required:
- error
description: The OpenAI-shaped envelope every error this endpoint itself produces uses, regardless of which of the four providers a request resolved to.
title: InferenceError
InferenceToolChoiceOneOf1Function:
type: object
properties:
name:
type: string
required:
- name
title: InferenceToolChoiceOneOf1Function
securitySchemes:
bearerAuth:
type: http
scheme: bearer
description: 'Your per-client bearer token — the API key the gateway issued to you. Present it in
`Authorization: Bearer <token>` form. A token that is missing, unknown, or revoked draws a
`401`. Before the call is sent upstream the token is removed (stripped, or swapped for the
upstream''s own credential); it never makes it past the gateway.
'