Skip to main content

No project description provided

Project description

Outerop Python SDK

The Outerop Python SDK provides a convenient way to interact with the Outerop API and integrate GenAI into your Python applications. It supports multiple providers, including OpenAI, Anthropic, and Mistral.

Installation

To install the Outerop Python SDK, use pip:

pip install outerop

Usage

To use the Outerop SDK, you need to create an instance of the Outerop class with your Outerop API key and optionally provide additional configuration options.

from outerop import Outerop

outerop = Outerop(outerop_api_key="YOUR_OUTEROP_API_KEY", options={
   "openaiApiKey": "YOUR_OPENAI_API_KEY",
   "anthropicApiKey": "YOUR_ANTHROPIC_API_KEY",
   "mistralApiKey": "YOUR_MISTRAL_API_KEY"
})

Using the SDK

To call the AI API with a specific prompt and variables, you can use the chat method:

result = outerop.chat(
   team_prompt_name"your-prompt-uuid",
   version_name_or_environment="development",
   variables={"name": "John", "age": "25"}
)

Pinning a specific version in version control

You can replace the environment parameter with a specific version number to pin a specific version of the prompt.

result = outerop.chat(
   team_prompt_name="your-prompt-uuid",
   version_name_or_environment="o-1234567890",
   variables={"name": "John", "age": "25"}
)

We recommend keeping the instantiation of the Outerop class outside your main event loop to allow the caching to work.

Response format

We standardise responses based on the OpenAI SDK for both python and JS. Other models outputs will be transformed to fit the schema. However if you need to, you can access the raw return from the API in the "raw" property of the response.

However we highly recommend using the standardised format, as it will allow you to switch models without changing your code.

Other methods

To retrieve a prompt, use the get_prompt method:

prompt = outerop.get_prompt(team_prompt_name="your-prompt-uuid", environment="development", version="latest")

Configuration

The Outerop class accepts an optional options parameter to configure additional settings:

  • baseURL: The base URL of the Outerop API (default: "https://app.outerop.com").
  • loggingEnabled: Enable or disable logging (default: True).
  • openaiApiKey: The API key for OpenAI.
  • anthropicApiKey: The API key for Anthropic.
  • mistralApiKey: The API key for Mistral.
  • bypassHeader: A bypass header for Vercel protection.

Logging

The SDK includes a built-in logging mechanism to capture chat events and send them to the Outerop API for analytics and monitoring purposes. Logging is enabled by default, but you can disable it by setting loggingEnabled to False in the options.

Error Handling

The SDK raises exceptions for various error scenarios, such as missing API keys, invalid responses, or network errors. Make sure to wrap your code in a try-except block to handle these exceptions gracefully.

Default Environments

The default environments are: testing development staging production

Contributing

Contributions to the Outerop Python SDK are welcome! If you find any issues or have suggestions for improvements, please open an issue or submit a pull request on the GitHub repository.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

outerop-0.2.2.tar.gz (4.8 kB view details)

Uploaded Source

Built Distribution

outerop-0.2.2-py3-none-any.whl (5.2 kB view details)

Uploaded Python 3

File details

Details for the file outerop-0.2.2.tar.gz.

File metadata

  • Download URL: outerop-0.2.2.tar.gz
  • Upload date:
  • Size: 4.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.7.1 CPython/3.10.8 Darwin/23.4.0

File hashes

Hashes for outerop-0.2.2.tar.gz
Algorithm Hash digest
SHA256 9e37f5524414201fb1cb00236a7dcc8c836f260c3d5e4887f13f6a42602d45ff
MD5 cc66f167520dedf3d9ee223a861082a0
BLAKE2b-256 c32890f0f0980eab7943632fbce7ecf4f9c745b72246101f7faa50863d776167

See more details on using hashes here.

File details

Details for the file outerop-0.2.2-py3-none-any.whl.

File metadata

  • Download URL: outerop-0.2.2-py3-none-any.whl
  • Upload date:
  • Size: 5.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.7.1 CPython/3.10.8 Darwin/23.4.0

File hashes

Hashes for outerop-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 4e66d1fe756f75e0e5ea4fef4f4a89ff49788bac83c9f26433584a495c043899
MD5 657016d1106e29b354ba2fb2bc18da3d
BLAKE2b-256 9608ae432169b17b20b242fe09125e7a990658713168074c15a541388c1acbac

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page