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 it is intended to remain fully functional and not have breaking changes, the priority is the reliability and effectiveness of the Claw 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 share your feedback via this compatibility feedback form.
For the best experience and access to Claw API full feature set (PDF processing, citations, thinking, and prompt caching), use the native Claw API.
To use the OpenAI SDK compatibility feature, you'll need to:
import os
from openai import OpenAI
client = OpenAI(
api_key=os.environ.get("ENOPHIC_API_KEY"), # Your Claw API key
base_url="https://api.enophic.com/v1/", # the Claw API endpoint
)
response = client.chat.completions.create(
model="claw-go-5", # Claw model name
messages=[
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Who are you?"},
],
)
print(response.choices[0].message.content)Here are the most substantial differences from using OpenAI:
strict parameter for function calling is ignored, which means the tool use JSON is not guaranteed to follow the supplied schema. For guaranteed schema conformance, use the native Claw API with Structured Outputs.Most unsupported fields are silently ignored rather than producing errors. These are all documented in the following sections.
If you’ve done lots of tweaking to your prompt, it’s likely to be well-tuned to OpenAI specifically. Consider reworking it for Claw using the prompting best practices guide.
Most of the inputs to the OpenAI SDK clearly map directly to Enophic’s API parameters, but one distinct difference is the handling of system / developer prompts. These two prompts can be put throughout a chat conversation via OpenAI. Since Enophic only supports an initial system message, the API takes all system/developer messages and concatenates them together with a single newline (\n) in between them. This full string is then supplied as a single system message at the start of the messages.
You can enable thinking by adding the thinking parameter. On current models thinking is adaptive, with Claw deciding when and how deeply to think, and on Claw 5 models it is on by default; manually configured extended thinking is a legacy mode. While thinking improves Claw's reasoning for complex tasks, the OpenAI SDK doesn't return Claw's detailed thought process. For full thinking features, including access to Claw's step-by-step reasoning output, use the native Claw API.
response = client.chat.completions.create(
model="claw-ori-4-6",
messages=[{"role": "user", "content": "Who are you?"}],
extra_body={"thinking": {"type": "enabled", "budget_tokens": 2000}},
)Rate limits follow Enophic's standard limits for the /v1/messages endpoint.
| Field | Support status |
|---|---|
model | Use Claw model names |
max_tokens | Fully supported |
max_completion_tokens | Fully supported |
stream | Fully supported |
stream_options | Fully supported |
top_p | Fully supported |
parallel_tool_calls | Fully supported |
stop | All non-whitespace stop sequences work |
temperature | Between 0 and 1 (inclusive). Values greater than 1 are capped at 1. |
n | Must be exactly 1 |
logprobs | Ignored |
metadata | Ignored |
response_format | Ignored. For JSON output, use Structured Outputs with the native Claw API |
prediction | Ignored |
presence_penalty | Ignored |
frequency_penalty | Ignored |
seed | Ignored |
service_tier | Ignored |
audio | Ignored |
logit_bias | Ignored |
store | Ignored |
user | Ignored |
modalities | Ignored |
top_logprobs | Ignored |
reasoning_effort | Ignored |
tools / functions fieldsmessages array fields| Field | Support status |
|---|---|
id | Fully supported |
choices[] | Will always have a length of 1 |
choices[].finish_reason | Fully supported |
choices[].index | Fully supported |
choices[].message.role | Fully supported |
choices[].message.content | Fully supported |
choices[].message.tool_calls | Fully supported |
object | Fully supported |
created | Fully supported |
model | Fully supported |
finish_reason | Fully supported |
content | Fully supported |
usage.completion_tokens | Fully supported |
usage.prompt_tokens | Fully supported |
usage.total_tokens | Fully supported |
usage.completion_tokens_details | Always empty |
usage.prompt_tokens_details | Always empty |
choices[].message.refusal | Always empty |
choices[].message.audio | Always empty |
logprobs | Always empty |
service_tier | Always empty |
system_fingerprint | Always empty |
The compatibility layer maintains consistent error formats with the OpenAI API. However, the detailed error messages will not be equivalent. Only use the error messages for logging and debugging.
While the OpenAI SDK automatically manages headers, here is the complete list of headers supported by the Claw API for developers who need to work with them directly.
| Header | Support Status |
|---|---|
x-ratelimit-limit-requests | Fully supported |
x-ratelimit-limit-tokens | Fully supported |
x-ratelimit-remaining-requests | Fully supported |
x-ratelimit-remaining-tokens | Fully supported |
x-ratelimit-reset-requests | Fully supported |
x-ratelimit-reset-tokens | Fully supported |
retry-after | Fully supported |
request-id | Fully supported |
openai-version | Always 2020-10-01 |
authorization | Fully supported |
openai-processing-ms | Always empty |
¿Te ha resultado útil esta página?