With a few code changes, you can use the OpenAI SDK to test the CustomGPT.ai API. We provide a compatibility layer that lets you quickly evaluate CustomGPT.ai’s capabilities with minimal effort while using your existing OpenAI-based code.
Feedback or Bugs?
This compatibility layer is in beta. Submit feedback or bugs related to the OpenAI SDK compatibility feature through our Slack Community
Before You Begin
This compatibility layer is intended primarily for quick experimentation and basic evaluations of how CustomGPT.ai compares to OpenAI. It is not a long-term, production-ready solution. For advanced features (such as richer conversation management, project-level model selection, or domain-specific indexing), we recommend using the native CustomGPT.ai SDK directly.
Getting Started with the OpenAI SDK
To use the OpenAI SDK compatibility feature against CustomGPT.ai’s API, you’ll need to:
- Use an official OpenAI SDK (e.g.,
openai
in Python). - Update your base URL to CustomGPT.ai’s compatibility endpoint.
- Use your CustomGPT.ai API key in place of the OpenAI API key.
- (Optional) Set a model name – though CustomGPT.ai ignores the model parameter at the moment and uses the model associated with your project.
- Review the supported/ignored fields listed in this document.
Quick Start Example (Python)
Below is a minimal code snippet showing how to point your OpenAI SDK calls to CustomGPT.ai.
from openai import OpenAI
client = OpenAI(
api_key="CUSTOMGPT_API_KEY", # Your CustomGPT.ai API key
base_url="https://app.customgpt.ai/api/v1/projects/{project_id}/" # Replace with your project ID
)
response = client.chat.completions.create(
model="gpt-4", # This will be ignored; your project's model will be used
messages=[
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Who are you?"}
],
)
print(response.choices[0].message.content)
Note
Other OpenAI endpoints (besideschat.completions
) are not supported. Requests to them will return a404
error.
Important OpenAI Compatibility Limitations
-
Only Completions
- CustomGPT.ai currently only supports the
ChatCompletion
endpoint for text completions. Any other endpoints (e.g., embeddings, audio, fine-tunes) will return404
.
- CustomGPT.ai currently only supports the
-
Model Name Is Ignored
- Although the OpenAI SDK requires a
model
parameter, CustomGPT.ai will ignore this and use the model configured for your CustomGPT.ai project.
- Although the OpenAI SDK requires a
-
Conversation Management
- Unlike OpenAI’s multi-message approach, CustomGPT.ai’s OpenAI-compatible endpoint expects you to manage conversation history. We do not store or manage conversation state internally for this compatibility layer.
-
Parameter Differences
- Many OpenAI parameters are either silently ignored or return a
501 Not Implemented
if they affect logic CustomGPT.ai doesn’t support. For example,temperature
,stop
, ormax_tokens
are currently ignored. See Request Fields for details.
- Many OpenAI parameters are either silently ignored or return a
-
Token Usage
- We do not return token usage metrics or detailed token breakdowns in the response. Fields like
usage
are omitted.
- We do not return token usage metrics or detailed token breakdowns in the response. Fields like
-
Unsupported Fields
- Certain fields (e.g.,
audio
,tools
, or advanced function-calling features) are explicitly not implemented and will return either404
or501
errors.
- Certain fields (e.g.,
-
Web search options are not supported and will return a 501 (Not Implemented) error.
-
Modalities are not supported and will return a 501 (Not Implemented) error.
Output Quality Considerations
If you have heavily tuned your prompts to work with OpenAI’s models, you may see different results when switching to CustomGPT.ai. We power our completions with our own underlying technology, which may lead to variations in style or reasoning. For more control and advanced features, use the native CustomGPT.ai SDK directly.
System / Developer Message Handling
OpenAI-style system messages are allowed, but CustomGPT.ai does not perform any special hoisting or single-system-message concatenation. We simply process messages in the order provided. Make sure to include your system or developer directives in the messages
array as needed.
Rate Limits
Requests through the compatibility endpoint follow your existing CustomGPT.ai plan limits. Refer to your CustomGPT.ai dashboard for usage details. We do not expose OpenAI-style rate limit headers through this compatibility layer.
Detailed OpenAI-Compatible API Support
Request Fields
Field | Support Status |
---|---|
messages | Required. Used to provide conversation prompts. |
model | Required by SDK, but ignored by CustomGPT.ai. |
stream | Supported. |
stream_options | Supported. |
max_tokens | Ignored. |
max_completion_tokens | Ignored. |
temperature | Ignored. |
top_p | Ignored. |
n | Ignored (only single completion returned). |
frequency_penalty | Ignored. |
presence_penalty | Ignored. |
stop | Ignored. |
logit_bias | Ignored. |
logprobs | Ignored. |
user | Ignored. |
metadata | Ignored. |
prediction | Ignored. |
seed | Ignored. |
reasoning_effort | Ignored. |
service_tier | Ignored. |
store | Ignored. |
top_logprobs | Ignored. |
modalities | Not implemented. Will return 501 . |
audio (format: wav, mp3, flac, opus, or pcm16) voice: alloy, ash, ballad, coral, echo, sage, and shimmer | Not implemented. Will return 404 . |
parallel_tool_calls | Not implemented. Will return 501 . |
tool_choice | Not implemented. Will return 501 . |
tools | Not implemented. Will return 501 . |
web_search_options | Not implemented. Will return 501 . |
response_format | Not implemented. Will return 501 . |
Note
If your request includes any of the “Not implemented” fields, it may result in a501 Not Implemented
or404
error.
Response Fields
-
id
A unique identifier for the response. -
object
Alwayschat.completion
. -
created_at
A Unix timestamp for when the response was generated. -
model
Reflects a placeholder model ID (e.g.,customgpt-compat
). -
choices[]
- Always returns a single choice (
choices[0]
). finish_reason
: string reason for completion ending.message.role
: typicallyassistant
.message.content
: the generated text.
- Always returns a single choice (
-
usage
- Not returned. No token usage details are provided.
Other OpenAI-specific fields (e.g., logprobs
, system_fingerprint
) are not returned or are empty.
Note that token usage information (completion_tokens, prompt_tokens, total_tokens) is not included in responses as this is not relevant to CustomGPT.ai's model implementation.
Error Message Compatibility
Where possible, we maintain the same HTTP status codes as OpenAI for text completions. However, the exact error messages will differ, reflecting CustomGPT.ai’s internal validations. Use the HTTP status code for handling logic, and refer to the response body for diagnostic details.
Header Compatibility
We do not return OpenAI-specific rate-limit headers or version headers. Please rely on CustomGPT.ai’s standard headers, or handle rate limiting via our native documentation.
Header | Status |
---|---|
x-ratelimit-* | Not returned. |
openai-version | Not returned. |
retry-after | Standard behavior only. |
openai-processing-ms | Not returned. |
Next Steps & Additional Resources
- Explore theCustomGPT.ai Cookbook for more robust code examples and advanced features.
- Use theCustomGPT.ai Native SDK when you need full functionality (batch requests, custom completions, conversation management, etc.).
- Join our Community to connect with other developers and get support.
If you have any questions or encounter issues, please reach out through our support portal. Thank you for trying CustomGPT.ai’s OpenAI compatibility layer!