Getting Started

This guide explains how to use Outerport’s Python SDK to make API calls.

Installation

You can install the Outerport Python SDK from PyPI (Python Package Index).

pip install outerport

Initializing the Client

To use the Outerport Python SDK, you need to first get your Outerport API key.

Currently, the Outerport API is invite only. To get access, please contact us at support@outerport.com.

Once you have your API key, you can initialize the client as follows:

from outerport import OuterportClient

client = OuterportClient(api_key="your_api_key")

Using a Self-Hosted Outerport API service

If you are hosting your own Outerport API, you can set the base_url to the URL of your hosted API.

client = OuterportClient(
    api_key="your_api_key",
    base_url="http://localhost:8080"
)

Basic Usage

Uploading a Document

You can upload a document using the client.documents.create method.

with open("document.pdf", "rb") as f:
    doc = client.documents.create(file=f)

The client.documents.create method returns a Document object.

The Outerport Python SDK returns an object when creating a “resource”. The returned object is connected to the client, so you can call the reload() method to get the latest data or the delete() method to delete it.

Asking a Question

You can ask a question about a document using the client.questions.create method.

question = client.questions.create(
    document_ids=[doc.id],
    question="What is our password policy?"
)

The client.questions.create method returns a Question object.

print(question.final_answer)

In addition to the question.final_answer, the question.plan and question.evidences contain the process of answering the question. For example, question.evidences returns the following result:

print(question.evidences)

Searching for Relevant Documents

You can search for relevant documents using the client.documents.search method.

documents = client.documents.search(query="Tell me about the password policy")

The client.documents.search method returns a list of Document objects.

You can also specify a tag or folder to search for.

documents = client.documents.search(
    query="Explain the password policy", 
    tag="security"
)