Getting Started with OpenAI API
Introduction
Welcome to the OpenAI Postman Collection! This collection provides a comprehensive set of examples to help you get started with the OpenAI API. Easily walkthrough multiple usecases, API Capabilities, and OpenAI's assistant APIs.
The OpenAI API provides a simple interface for developers to create an intelligence layer in their applications powered by OpenAI's state-of-the-art models. The Chat Completions endpoint powers ChatGPT and provides a straightforward way to generate text responses.
Note: This collection is part of a workspace curated by the Postman team to help you explore and work with useful APIs. Learn how to contribute to this collaborative space and its collections here.
Getting Started
Step 1: Fork the Collection
Fork the Collection manually or by clicking the Run in Postman button
Step 2: Setup your account
Create an OpenAI account or sign in to an existing one.
Step 3: Fetch your API key
Next, navigate to the API keys page and click on the "Create new secret key" button.
Give your key a name, select a project, and configure all relevant permissions for this API key.
Create the secret key.
Once the Secret Key is created, copy it to your clipboard by clicking the copy button and select "Done" to close the open prompt.
Step 4: Configure the API Key in Postman
Postman provides you with a Vault that let's you store sensitive data locally. Data stored in this vault is not synced with Postman Cloud and can only be accessed in your local Postman Instance.
Using the table below as a guide, add your keys to your vault. A reference to a secret {{vault:openai-secret-key}}} has been added to the collection authorization tab as a Bearer token to be automatically used with all requests in this workspace. If you do not use the same variable name in your vault, please update the authorization tab accordingly.
| Key | Value | Allowed Domains |
|---|---|---|
openai-secret-key |
your_key_value | https://api.openai.com |
There are three folders in this collection.
-
OpenAI API - Use Cases: Documents several interesting use cases of the OpenAI API.
-
OpenAI API capabilities: Documents the OpenAI API and includes most of the requests and interfaces that the API exposes. It makes use of the scripts tab to build basic workflows where necessary and test for assertions against the API response.
-
OpenAI Assistants API: Documents the new Assistants API (in Beta) which is designed to help developers build powerful AI assistants capable of performing a variety of tasks
OpenAI API Use Cases
-
Build a simple FAQ system
OpenAI API Capabilities
-
Fine Tuning
-
Batch API Requests
-
Files
-
Image Generation
-
Models
OpenAI Assistants API
-
Threads
-
Messages
-
Runs
-
Vector Store
-
Vectore Store Files
Getting Help
We want you to get the best support you can when working with this workspace. If you're stuck and you need help regarding OpenAI specific issues, we recommend that you explore the following channels.
For Postman specific questions or feedback about this workspace:
- Postman's Community Forum - Provide feedback and ask questions about this workspace, ask general Postman questions, understand how to use a feature, how to build a workflow, etc.
For Postman specific issues:
- Postman Github Issues - Submit feature requests, bug reports, etc here
Install the Package
The package is compatible with Python versions 3.7+.
Install the package from PyPi using the following pip command:
pip install Apimatic-open-api-sdk==1.0.0
You can also view the package at: https://pypi.python.org/pypi/Apimatic-open-api-sdk/1.0.0
Test the SDK
You can test the generated SDK and the server with test cases. unittest is used as the testing framework and pytest is used as the test runner. You can run the tests as follows:
Navigate to the root directory of the SDK and run the following commands
pip install -r test-requirements.txt pytest
Initialize the API Client
Note: Documentation for the client can be found here.
The following parameters are configurable for the API Client:
| Parameter | Type | Description |
|---|---|---|
| environment | Environment |
The API environment. Default: Environment.PRODUCTION |
| http_client_instance | HttpClient |
The Http Client passed from the sdk user for making requests |
| override_http_client_configuration | bool |
The value which determines to override properties of the passed Http Client from the sdk user |
| http_call_back | HttpCallBack |
The callback value that is invoked before and after an HTTP call is made to an endpoint |
| timeout | float |
The value to use for connection timeout. Default: 60 |
| max_retries | int |
The number of times to retry an endpoint call if it fails. Default: 0 |
| backoff_factor | float |
A backoff factor to apply between attempts after the second try. Default: 2 |
| retry_statuses | Array of int |
The http statuses on which retry is to be done. Default: [408, 413, 429, 500, 502, 503, 504, 521, 522, 524] |
| retry_methods | Array of string |
The http methods on which retry is to be done. Default: ['GET', 'PUT'] |
| bearer_auth_credentials | BearerAuthCredentials |
The credential object for OAuth 2 Bearer token |
The API client can be initialized as follows:
from openaiapi.configuration import Environment
from openaiapi.http.auth.o_auth_2 import BearerAuthCredentials
from openaiapi.openaiapi_client import OpenaiapiClient
client = OpenaiapiClient(
bearer_auth_credentials=BearerAuthCredentials(
access_token='AccessToken'
),
environment=Environment.PRODUCTION
)
Authorization
This API uses the following authentication schemes.
List of APIs
- Text Generation-Chat Completions API
- Function Calling-Chat Completions API
- Builda Simple FAQ System-Embeddings API
- Chat Completions
- Structured Outputs
- Predicted Outputs
- Fine Tuning
- Batch API Requests
- Image Generation
- Vector Store Files
- Vector Store
- Open AI Assistants API-Beta
- Reasoning
- Embeddings
- Files
- Models
- Moderations
- Messages
- Runs
- Threads
- Batches
SDK Infrastructure
HTTP
Utilities
Metadata
Release files for Apimatic-open-api-sdk 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| apimatic_open_api_sdk-1.0.0.tar.gz | 75.6 kB | Without provenance | Details for apimatic_open_api_sdk-1.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| apimatic_open_api_sdk-1.0.0-py3-none-any.whl | Python 3 | none | any | Details for apimatic_open_api_sdk-1.0.0-py3-none-any.whl |
Total release size: 316.0 kB
Release files / apimatic_open_api_sdk-1.0.0.tar.gz
| Download URL | apimatic_open_api_sdk-1.0.0.tar.gz |
|---|---|
| Size | 75.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2755a5b27b5bba9fe42d28c354206d56e276b0b494c62a72084aa1252120bc0d
|
|
BLAKE2b-256 checksum How to use checksums |
bebdc25a74a1bb47614720dfed0021b74e13421d99254a5109e4714674732278
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.9.13
|
Release files / apimatic_open_api_sdk-1.0.0-py3-none-any.whl
| Download URL | apimatic_open_api_sdk-1.0.0-py3-none-any.whl |
|---|---|
| Size | 240.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ed0eeaa49ce69743b962e780ba29b822342bdb3719429899f078eeaa431d655f
|
|
BLAKE2b-256 checksum How to use checksums |
d720ce50056341ed404fbc3432e061b5efb9cc5d73aca2fea7bf1da9e9c1aa93
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.9.13
|
Security for Apimatic-open-api-sdk 1.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.