Set up OpenAI
Researched from OpenAI's official documentation on 2026-11-02. Not yet walked through end to end.
Open your OpenAI console (sign-in required)
- Current: Choose an organization and project
Sign in to the OpenAI API Platform or create an account there. Select the organization and project you will use.
- Not started: Create a project API key
Open API keys, create a project key with the permissions your application needs, and store it privately on your own machine.
- Not started: Check billing and model access
Check the API billing and usage limits for that project. A key alone does not establish paid model access.
- Not started: Configure your .env
Use the environment names below in your own application. Keep its environment file out of source control. Never paste a key into this website.
- Not started: Run the local check
Choose a model you can use and run the matching example below on your own machine. Check any applicable usage charges first.
Configure and verify locally
Environment names and defaults below come from the installed package. Choose a model you can use by setting PRISM_SETUP_MODEL on your machine. Run the verification only when you are ready for one billed request. No request is sent by this page.
Approximate text cost is input tokens × your model’s input rate, plus at most 32 output tokens × its output rate, divided by the rate’s token unit. Add any provider fees. Check your model and region’s current price; the token limit is not a money cap.
use Prism\Prism\Facades\Prism;
// Run in your own configured Laravel app (for example, php artisan tinker).
$model = getenv('PRISM_SETUP_MODEL');
if (!$model) {
throw new RuntimeException('Set PRISM_SETUP_MODEL to your model.');
}
try {
$result = Prism::text()
->using('openai', $model)
->withPrompt('Say hello.')
->withMaxTokens(32)
->asText();
echo $result->text, PHP_EOL;
} catch (Throwable $error) {
echo get_class($error), PHP_EOL;
}