Skip to content

Commit

Permalink
[info] set OpenAI-Project header
Browse files Browse the repository at this point in the history
  • Loading branch information
Benjaminhu committed Sep 22, 2024
1 parent d8c78fe commit 449157d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -311,16 +311,17 @@ use Orhanerday\OpenAi\OpenAi;
$open_ai = new OpenAi(env('OPEN_AI_API_KEY'));
```

## Requesting organization
## Requesting organization, project (optional)

For users who belong to multiple organizations, you can pass a header to specify which organization is used for an API
For users who belong to multiple organizations, projects, you can pass a header to specify which organization, project is used for an API
request.
Usage from these API requests will count against the specified organization's subscription quota.

````php
$open_ai_key = getenv('OPENAI_API_KEY');
$open_ai = new OpenAi($open_ai_key);
$open_ai->setORG("org-IKN2E1nI3kFYU8ywaqgFRKqi");
$open_ai->setORG('<YOUR-ORG-ID>');
$open_ai->setProject('<YOUR-PROJECT-ID>');
````

## Base URL
Expand Down
12 changes: 11 additions & 1 deletion src/OpenAi.php
Original file line number Diff line number Diff line change
Expand Up @@ -939,7 +939,17 @@ public function setORG(string $org)
$this->headers[] = "OpenAI-Organization: $org";
}
}


/**
* @param string $project
*/
public function setProject(string $project)
{
if ($project != "") {
$this->headers[] = "OpenAI-Project: $project";
}
}

/**
* @param string $org
*/
Expand Down

0 comments on commit 449157d

Please sign in to comment.