openai/openai-go

Access custom Assistants through API

jairogloz opened this issue · 3 comments

I'm building a Golang API that leverages ChatGPT for some tasks, and I’ve had good success using the openai-go package to interact with the standard models (e.g., gpt-3.5-turbo).

However, sometimes the responses I get don’t exactly match the structure I need. To solve this, I decided to create a custom assistant in the OpenAI dashboard, which I’ve fine-tuned to provide the exact response format I’m looking for.

It works as expected in the OpenAI playground, but I’m struggling to access this custom assistant via the API.

What I've tried:

  • I replaced the model field in the my request with the assistant ID I got from the OpainAI dashboard (something like asst_XXXX).
  • When I send the request, I get the following error:
POST "https://api.openai.com/v1/chat/completions": 404 Not Found 
{
    "error": {
        "message": "The model `asst_XXXXX` does not exist or you do not have access to it.",
        "type": "invalid_request_error",
        "param": null,
        "code": "model_not_found"
    }
}

My question:

Is it possible to interact with a custom assistant created in the OpenAI dashboard via the API? If so, how can I access it, and do I need to use a different endpoint or approach compared to the standard models?

Any guidance on how to achieve this would be greatly appreciated.

Thanks for bringing this up! I'll give this some investigation. Are you able to confirm whether this works in either the Python or Node SDKs?

I kept reading the documentation and I understand now that the assistants work through a different api (here is the doc) and workflow, where you need to create threads, then add messages to these threads and finally create "runs" for such thread where you can specify your assistant id.

It will be nice to have access to that through this package though.

Glad to hear you were able to figure this out, we'll have an example up for assistants shortly.