Search code examples
phpopenai-api

problem installing "OpenAI PHP SDK" in PHP project


I want to use OpenAI requests in my PHP project. So on the net I found I should install "OpenAI PHP SDK" with the composer require openai/api command.

However, composer gives me this error message: Could not find a matching version of package openai/api. Check the package spelling, your version constraint and that the package is available in a stability which matches your minimum-stability (dev).

From this I cannot understand what should I do. The package spelling should be ok. The version constraint (>8.1) also.


Solution

  • You are requiring the wrong package. There isn't any package named openai/api. You can use these packages to make requests to open ai.

    Here's the list in case you don't want to login into openai:

    1. orhanerday/open-ai
    2. tectalic/openai
    3. openai-php/client

    For example, you can run this command too add the third package: composer require openai-php/client