OpenAI SDK compatibility

NeosantaraAI provides a compatibility layer that enables you to use the OpenAI SDK to test the NeosantaraAI API. With a few code changes, you can quickly evaluate NeosantaraAI model capabilities.
This compatibility layer is primarily intended to test and compare model capabilities, and is not considered a long-term or production-ready solution for most use cases. While we do intend to keep it fully functional and not make breaking changes, our priority is the reliability and effectiveness of the NeosantaraAI API.For more information on known compatibility limitations, see Important OpenAI compatibility limitations.If you encounter any issues with the OpenAI SDK compatibility feature, please let us know at help@neosantara.xyz.
For the best experience and access to NeosantaraAI API full feature set, we recommend using our native API (check getting started guide).

Getting started with the OpenAI SDK

To use the OpenAI SDK compatibility feature, you’ll need to:
  1. Use an official OpenAI SDK
  2. Change the following
  3. Review the documentation below for what features are supported

Quick start example

from openai import OpenAI

client = OpenAI(
    api_key="NEOSANTARA_API_KEY",  # Your NeosantaraAI API key
    base_url="[https://api.neosantara.xyz/v1/](https://api.neosantara.xyz/v1/)"  # NeosantaraAI's API endpoint
)

response = client.chat.completions.create(
    model="nusantara-base", # NeosantaraAI model name
    messages=[
        {"role": "system", "content": "You are a helpful assistant."},
        {"role": "user", "content": "Who are you?"}
    ],
)

print(response.choices[0].message.content)

Important OpenAI compatibility limitations

API behavior

Here are the most substantial differences from using OpenAI:
  • The strict parameter for function calling is ignored, which means the tool use JSON is not guaranteed to follow the supplied schema.
  • Audio input is not supported; it will simply be ignored and stripped from input
  • Prompt caching is not supported
  • System messages are prepended to the first user message for some models.
Most unsupported fields are silently ignored rather than producing errors. These are all documented below.

Output quality considerations

If you’ve done lots of tweaking to your prompt, it’s likely to be well-tuned to OpenAI specifically.

System / Developer message hoisting

Most of the inputs to the OpenAI SDK clearly map directly to NeosantaraAI’s API parameters, but one distinct difference is the handling of system prompts. System messages are handled by prepending their content to the first user message for some underlying models, or passed as a system role to others.

Extended thinking support

NeosantaraAI supports advanced reasoning capabilities via its dedicated /v1/reasoning endpoint. This Anthropic-specific thinking parameter is ignored.
response = client.chat.completions.create(
    model="nusantara-base",
    messages=...,
    # The 'thinking' parameter here will be ignored by NeosantaraAI
    extra_body={
        "thinking": { "type": "enabled", "budget_tokens": 2000 }
    }
)

Rate limits

Rate limits follow NeosantaraAI’s standard limits.

Detailed OpenAI Compatible API Support

Request fields

Simple fields

FieldSupport status
modelUse NeosantaraAI model names
max_tokensFully supported
max_completion_tokensIgnored (use max_tokens instead)
streamFully supported
stream_optionsIgnored
top_pFully supported
parallel_tool_callsSupported via tools array
stopFully supported
temperatureFully supported
nMust be exactly 1
logprobsIgnored
metadataIgnored
response_formatFully supported (text, json_object)
predictionIgnored
presence_penaltyFully supported
frequency_penaltyFully supported
seedIgnored
service_tierIgnored
audioIgnored
logit_biasIgnored
storeIgnored
userIgnored
modalitiesIgnored
top_logprobsIgnored
reasoning_effortIgnored (use /v1/reasoning endpoint instead)

tools / functions fields

messages array fields

Error message compatibility

The compatibility layer maintains consistent error formats with the OpenAI API. However, the detailed error messages will not be equivalent. We recommend only using the error messages for logging and debugging.

Header compatibility

While the OpenAI SDK automatically manages headers, here is the complete list of headers supported by NeosantaraAI’s API for developers who need to work with them directly.
HeaderSupport Status
x-ratelimit-limit-requestsFully supported
x-ratelimit-limit-tokensFully supported
x-ratelimit-remaining-requestsFully supported
x-ratelimit-remaining-tokensFully supported
x-ratelimit-reset-requestsFully supported
x-ratelimit-reset-tokensFully supported
retry-afterNot supported
request-idNot supported
openai-versionNot supported
authorizationFully supported
openai-processing-msNot supported