Hello everyone,
I’m trying to interact with an assistant I created via OpenAI’s API, but I’m encountering an error regarding an invalid URL when calling the /assistants/{id}/completions
endpoint. Here’s the error message:
{
"error": {
"message": "Invalid URL (POST /v1/assistants/{id}/completions)",
"type": "invalid_request_error",
"param": null,
"code": null
}
}
It seems that the endpoint is not recognized, but I can’t figure out why. I’m using the OpenAI-Beta
header for assistants, as the docs suggest the /assistants
endpoint is in beta. Below is my C# code:
public async Task<OperationResult<ChatGptApiResponse>> Assistant(string message, IEnumerable list)
{
var apiEndpoint = "/assistants/ID/completions"; // Replaced "ID" with my assistant ID
var requestBody = new
{
messages = new[]
{
new { role = "user", content = message }
},
max_tokens = 150,
temperature = 0.7
};
var headers = new List<KeyValuePair<string, string>>
{
new ("OpenAI-Beta", "assistants=v2"),
};
var response = await ChatGptClient.PostAsync<ChatGptApiResponse>(apiEndpoint, requestBody, headers);
if (response is { Status: true, Data: not null })
{
return new OperationResult<ChatGptApiResponse> { Data = response.Data, Status = true };
}
Console.WriteLine($"Error: {response.Message}");
return new OperationResult<ChatGptApiResponse> { Message = "Not implemented", Status = false };
}
Things I’ve Tried:
- Verified the assistant ID is correct.
- Added the
OpenAI-Beta: assistants=v2
header as the docs suggest. - Looked for alternative endpoints, but I haven’t found a clear answer.
Question:
Has anyone successfully interacted with an assistant created via OpenAI’s API? Am I missing something in the URL or request structure? Is this endpoint /v1/assistants/{id}/completions
supported, or should I use a different approach to call the assistant?
Thank you!