Need Help: Accessing My Custom GPT Model via API

Hello everyone,

I hope someone here can help me. I have created and trained a custom GPT model, and now I want to access it via the API. I am using the OpenAI API and already have a ChatGPT Plus membership. Here are the details of my current situation:

My current cURL request:

// Initializing cURL
$ch = curl_init();

$gpt_api_url = ""; // Replace with the actual API URL for my custom model
$gpt_api_key = "your_api_key"; // Replace with my actual API key

// Preparing data for the request
$json_data = json_encode([
    "model" => "my_custom_model", // Replace with the name of my custom model
    "messages" => [
            "role" => "user",
            "content" => "Please provide a detailed response to a business email where I am canceling a meeting." // Clear and specific prompt
    "max_tokens" => 150 // Number of desired tokens

curl_setopt($ch, CURLOPT_URL, $gpt_api_url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $json_data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    'Content-Type: application/json',
    'Authorization: Bearer ' . $gpt_api_key

// Executing the request and storing the response
$response = curl_exec($ch);

// Checking for errors
if (curl_errno($ch)) {
    echo 'Error:' . curl_error($ch);
} else {
    // Processing the response
    $response_data = json_decode($response, true);

// Closing the cURL session

type or paste code here

The problem:

I am getting the following error message:

Array ( [error] => Array ( [message] => The model my_custom_model does not exist or you do not have access to it. [type] => invalid_request_error [param] => [code] => model_not_found ) )

My questions:

  1. Do I need special permissions to access my custom model?

  2. Do I need a special API endpoint for custom models?

  3. Are there additional steps or settings I need to check to ensure my model is available and accessible?

I have already made sure that my model is correctly created and deployed and that I am using the correct API key.

Thanks in advance for your help!

Best regards,


Short answer: it’s not possible.

Custom GPTs are designed to be accessed only via the ChatGPT interfaces. They can interact with APIs but they cannot be automated by external APIs.
For this you need to create an Assistant or build some other type of app on top of the API.

The model parameter you are using only accepts the models listed on this page.

I now have a script that my assistant uses. However, I now get an error message again.



// PHP-Fehlerberichte aktivieren
ini_set('display_errors', 1);

require '../../../../vendor/autoload.php'; // Guzzle und andere Abhängigkeiten laden

use GuzzleHttp\Client;

// Fester API-Schlüssel
$apiKey = 'xxxxxxxx'; // Setze hier deinen OpenAI API-Schlüssel ein

if (!$apiKey) {
    die('Error: OPENAI_API_KEY not set in code.');

function callOpenAI($prompt, $apiKey) {
    $model = 'asst_PgAGLuUsHO9f2OH3UiQqVcsM'; // Verwende die Modell-ID deines Feintuning-Modells
    $url = '';

    $client = new Client();
    try {
        $response = $client->post($url, [
            'headers' => [
                'Authorization' => 'Bearer ' . $apiKey,
                'Content-Type' => 'application/json',
            'json' => [
                'model' => $model,
                'prompt' => $prompt,
                'max_tokens' => 500,
                'temperature' => 0.7,

        if ($response->getStatusCode() !== 200) {
            return 'Error contacting OpenAI API: ' . $response->getReasonPhrase();

        $responseObject = json_decode($response->getBody(), true);
        return trim($responseObject['choices'][0]['text']);
    } catch (Exception $e) {
        return 'Error: ' . $e->getMessage();

// Beispiel-Prompt
$prompt = "Hello, how are you?";

// OpenAI API aufrufen
$response = callOpenAI($prompt, $apiKey);

// Antwort ausgeben
echo "Response from OpenAI: " . $response;


Response from OpenAI: Error: Client error: POST resulted in a 404 Not Found response: { “error”: { “message”: "The model asst_PgAGLuUsHO9f2OH3UiQqVcsM does not exist or you do not have access (truncated…)

What i can do?