You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+68-11Lines changed: 68 additions & 11 deletions
Original file line number
Diff line number
Diff line change
@@ -20,7 +20,7 @@ Stream text with GPT-4, transcribe and translate audio with Whisper, or create i
20
20
-[Installation](#installation)
21
21
-[Bundler](#bundler)
22
22
-[Gem install](#gem-install)
23
-
-[Usage](#usage)
23
+
-[How to use](#how-to-use)
24
24
-[Quickstart](#quickstart)
25
25
-[With Config](#with-config)
26
26
-[Custom timeout or base URI](#custom-timeout-or-base-uri)
@@ -65,6 +65,7 @@ Stream text with GPT-4, transcribe and translate audio with Whisper, or create i
65
65
-[Translate](#translate)
66
66
-[Transcribe](#transcribe)
67
67
-[Speech](#speech)
68
+
-[Usage](#usage)
68
69
-[Errors](#errors-1)
69
70
-[Development](#development)
70
71
-[Release](#release)
@@ -102,7 +103,7 @@ and require with:
102
103
require"openai"
103
104
```
104
105
105
-
## Usage
106
+
## How to use
106
107
107
108
- Get your API key from [https://platform.openai.com/account/api-keys](https://platform.openai.com/account/api-keys)
108
109
- If you belong to multiple organizations, you can get your Organization ID from [https://platform.openai.com/account/org-settings](https://platform.openai.com/account/org-settings)
@@ -125,6 +126,7 @@ For a more robust setup, you can configure the gem with your API keys, for examp
config.admin_token =ENV.fetch("OPENAI_ADMIN_TOKEN") # Optional, used for admin endpoints, created here: https://platform.openai.com/settings/organization/admin-keys
config.log_errors =true# Highly recommended in development, so you can see what errors OpenAI is returning. Not recommended in production because it could leak private data to your logs.
130
132
end
@@ -136,10 +138,10 @@ Then you can create a client like this:
136
138
client =OpenAI::Client.new
137
139
```
138
140
139
-
You can still override the config defaults when making new clients; any options not included will fall back to any global config set with OpenAI.configure. e.g. in this example the organization_id, request_timeout, etc. will fallback to any set globally using OpenAI.configure, with only the access_token overridden:
141
+
You can still override the config defaults when making new clients; any options not included will fall back to any global config set with OpenAI.configure. e.g. in this example the organization_id, request_timeout, etc. will fallback to any set globally using OpenAI.configure, with only the access_token and admin_token overridden:
config.admin_token=ENV.fetch("OPENAI_ADMIN_TOKEN")# Optional, used for admin endpoints, created here: https://platform.openai.com/settings/organization/admin-keys
# => mp3 file that plays: "This is a speech test!"
1461
1464
```
1462
1465
1466
+
### Usage
1467
+
The Usage API provides information about the cost of various OpenAI services within your organization.
1468
+
To use Admin APIs like Usage, you need to set an OPENAI_ADMIN_TOKEN, which can be generated [here](https://platform.openai.com/settings/organization/admin-keys).
@@ -1481,15 +1542,11 @@ To install this gem onto your local machine, run `bundle exec rake install`.
1481
1542
To run all tests, execute the command `bundle exec rake`, which will also run the linter (Rubocop). This repository uses [VCR](https://github.com/vcr/vcr) to log API requests.
1482
1543
1483
1544
> [!WARNING]
1484
-
> If you have an `OPENAI_ACCESS_TOKEN` in your `ENV`, running the specs will use this to run the specs against the actual API, which will be slow and cost you money - 2 cents or more! Remove it from your environment with `unset` or similar if you just want to run the specs against the stored VCR responses.
1545
+
> If you have an `OPENAI_ACCESS_TOKEN`and `OPENAI_ADMIN_TOKEN`in your `ENV`, running the specs will hit the actual API, which will be slow and cost you money - 2 cents or more! Remove them from your environment with `unset` or similar if you just want to run the specs against the stored VCR responses.
1485
1546
1486
1547
## Release
1487
1548
1488
-
First run the specs without VCR so they actually hit the API. This will cost 2 cents or more. Set OPENAI_ACCESS_TOKEN in your environment or pass it in like this:
1489
-
1490
-
```
1491
-
OPENAI_ACCESS_TOKEN=123abc bundle exec rspec
1492
-
```
1549
+
First run the specs without VCR so they actually hit the API. This will cost 2 cents or more. Set OPENAI_ACCESS_TOKEN and OPENAI_ADMIN_TOKEN in your environment.
1493
1550
1494
1551
Then update the version number in `version.rb`, update `CHANGELOG.md`, run `bundle install` to update Gemfile.lock, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
0 commit comments