Search code examples
openai-apichatgpt-api

OpenAI Chat Completions API: Can I use a fine-tuned GPT-3 model with the GPT-3.5 API endpoint (error: "Invalid URL (POST /v1/chat/completions)")?


After we create a fine-tuned model, how can we use it at /v1/chat/completions? We tried this but it gave an error

curl --location 'https://api.openai.com/v1/chat/completions' \
--header 'Authorization: Bearer TOKEN' \
--header 'Content-Type: application/json' \
--data '{
    "model": "davinci:ft-xxx-inc:6302f74d2000001f00f80919-2023-04-15-00-47-48",
    "messages": [
        {
            "role": "user",
            "content": "How to use apple vision api to recognize text? any example?"
        }
    ]
}'
// Error
{
    "error": {
        "message": "Invalid URL (POST /v1/chat/completions)",
        "type": "invalid_request_error",
        "param": null,
        "code": null
    }
}

Solution

  • It seems like you wanted to fine-tune the GPT-3 davinci model and use it with the GPT-3.5 API endpoint.

    You can fine-tune the davinci model as stated in the official OpenAI documentation:

    Fine-tuning is currently only available for the following base models: davinci, curie, babbage, and ada. These are the original models that do not have any instruction following training (like text-davinci-003 does for example). You are also able to continue fine-tuning a fine-tuned model to add additional data without having to start from scratch.

    But... The davinci model is not compatible with the /v1/chat/completions API endpoint as stated in the official OpenAI documentation:

    ENDPOINT MODEL NAME
    /v1/chat/completions gpt-4, gpt-4-0613, gpt-4-32k, gpt-4-32k-0613, gpt-3.5-turbo, gpt-3.5-turbo-0613, gpt-3.5-turbo-16k, gpt-3.5-turbo-16k-0613
    /v1/completions text-davinci-003, text-davinci-002, text-curie-001, text-babbage-001, text-ada-001
    /v1/edits text-davinci-edit-001, code-davinci-edit-001
    /v1/audio/transcriptions whisper-1
    /v1/audio/translations whisper-1
    /v1/fine-tunes davinci, curie, babbage, ada
    /v1/embeddings text-embedding-ada-002, text-search-ada-doc-001
    /v1/moderations text-moderation-stable, text-moderation-latest