Settings

Theme

RAG API + OpenAI compatibility

docs.customgpt.ai

3 points by pkhodiyar 9 months ago · 1 comment

Reader

pkhodiyarOP 9 months ago

Hey HN,

We’ve just rolled out an OpenAI-Compatible Endpoint at CustomGPT.ai that should make it super easy to try Retrieval-Augmented Generation (RAG) in your existing OpenAI-based code.

Now, hundreds of tools in the OpenAI ecosystem can add RAG capabilities with minimal changes.

Docs here - https://docs.customgpt.ai/reference/customgptai-openai-sdk-c...

All you do is: 1. Swap your api_key to the CustomGPT one, 2. Change the base_url to our endpoint. And thats it.

You can keep using your OpenAI Python SDK code. Under the hood, we handle context retrieval from your project knowledge sources before generating a final answer.

We support the chat.completions endpoint with the same request/response structure. If you call an unsupported endpoint, we return a 404 or 501.

This opens up the entire ecosystem of OpenAI-compatible tools, frameworks, and services for your RAG workflows. Everything else—conversation format, message handling, etc.—remains the same.

Check out a quick Python snippet:

from openai import OpenAI client = OpenAI( api_key="CUSTOMGPT_API_KEY", base_url="https://app.customgpt.ai/api/v1/projects/{project_id}/" ) response = client.chat.completions.create( model="gpt-4", # We'll ignore the model param and use your project's default messages=[ {"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Who are you?"} ], ) print(response.choices[0].message.content)

We’re ignoring certain OpenAI parameters like model and temperature. If you try to call an endpoint we don’t support, you’ll get a 404 or 501. Otherwise, your code runs pretty much the same.

We built this because we kept hearing people say, “I’d like to try CustomGPT.ai for better context retrieval, but I already have so much code in the OpenAI ecosystem.” Hopefully this bridges the gap. Feedback and PR requests are welcome. Let us know how it goes!

Hope this helps folks who’ve been on the fence about trying RAG but don’t want to break everything they already have running!

If you have any question regrading the implementation, please ask below

Keyboard Shortcuts

j
Next item
k
Previous item
o / Enter
Open selected item
?
Show this help
Esc
Close modal / clear selection