Skip to main content
NEAR AI Cloud implements the OpenAI-compatible inference surfaces documented below. You can use the official OpenAI client libraries for Python and JavaScript/TypeScript by changing the base URL and API key. Features that require provider-side storage or tool execution are intentionally limited; each section describes the supported contract.

Configuration

To use the OpenAI SDKs with NEAR AI Cloud, you simply need to override the base_url and provide your NEAR AI api_key.

Base URL

Use the NEAR AI Cloud Gateway base URL:

API Key

You can generate your API key in the NEAR AI Cloud Dashboard.

Request IDs

Gateway responses from https://cloud-api.near.ai/v1 include an X-Request-Id response header. Support may ask you for this value when debugging a request. X-Request-Id is opaque support/debugging metadata; it is not W3C traceparent or distributed trace context. If you send your own X-Request-Id, use a non-sensitive UUID value. X-Request-Id values must not contain secrets or PII. X-Org-Id and X-Workspace-Id are internal tenant headers; public clients cannot set or override them.

Usage Examples

Python SDK

First, install the OpenAI Python library:
Then, initialize the client with NEAR AI configuration:

Async Usage

Supported Features

NEAR AI Cloud supports the following core OpenAI API features:
  • Chat Completions (/v1/chat/completions) - Including tool calling, structured outputs, and reasoning
  • Completions (/v1/completions) - Legacy text completions
  • Models List (/v1/models)
  • Embeddings (/v1/embeddings) - See Beyond Chat
  • Images (/v1/images/generations, /v1/images/edits) - See Beyond Chat
  • Audio Transcription (/v1/audio/transcriptions) - See Beyond Chat
  • Responses (/v1/responses) - Stateless, store: false inference with client-managed history and custom functions; see Stateless Responses
  • Streaming (Server-Sent Events)
NEAR AI Cloud also provides non-OpenAI extensions:
  • Reranking (/v1/rerank) - Score documents against a query
  • Privacy classification (/v1/privacy/classify) - Detect personally identifiable information through the gateway
  • Privacy redaction (/v1/privacy/redact) - Gateway-only endpoint for redacting personally identifiable information
  • Attestation & Signatures (/v1/attestation/report, /v1/signature/{chat_id}) - See Verification

Stateless Responses

The Responses API preserves the OpenAI Responses input, output, and streaming shapes without storing conversation or response history. Set store: false or omit it, and include any prior context in each new request.
See Stateless Responses for caller-managed multi-turn history, custom function replay, retired endpoints, and unsupported server-executed tools.

Environment Variables

Alternatively, you can set the environment variables to avoid hardcoding credentials in your code:
Then you can initialize the client without arguments: