Skip to main content

The official Python library for the Tela API

Project description

Tela SDK for Python

The Tela SDK for Python provides a simple and powerful way to interact with the Tela API. This SDK allows you to create chat completions, handle file uploads, and manage various resources with ease.

Table of Contents

Installation

You can install the Tela SDK using pip:

pip install tela

Usage

First, you need to import the SDK and initialize it with your API key:

from tela import create_tela_client

tela = create_tela_client(api_key='your-api-key')

Examples

Simple Completion

This example demonstrates how to create a simple completion using a PDF document:

from tela import create_tela_client, create_tela_file

tela = create_tela_client(
    api_key='your-api-key',
)

completion = tela.completions.create({
    canvas_id='your-canvas-id',
    variables={
        "document": create_tela_file("https://www.wmaccess.com/downloads/sample-invoice.pdf"),
    },
})
print(completion)

Chat Completion

This example shows how to create a chat completion with a simple message:

from tela import create_tela_client

tela = create_tela_client(
    api_key='your-api-key',
)
completion = tela.completions.create({
    canvas_id='your-canvas-id',
    messages=[{'role': 'user', 'content': 'Hello!'}],
})
print(completion)

Webhook Completion

This example demonstrates how to create a completion that sends the result to a webhook URL:

from tela import create_tela_client, create_tela_file

tela = create_tela_client(
    api_key='your-api-key',
)

webhook = tela.completions.create({
    canvas_id='your-canvas-id',
    variables={
        document: create_tela_file("https://www.wmaccess.com/downloads/sample-invoice.pdf"),
    },
    webhook_url='https://webhook.site/4294967295',
    stream=False,
})
print(webhook)

Streaming Completion

This example shows how to handle streaming responses:

from tela import create_tela_client, create_tela_file

tela = create_tela_client(
    api_key='your-api-key',
)

with open('sample-invoice.pdf', 'rb') as file:
    completion = tela.completions.create({
        canvas_id='your-canvas-id',
        variables={
            'document': create_tela_file(file),
        },
        stream=True,
    })
    for chunk in completion:
        print(chunk)

Contributing

We welcome contributions to the Tela SDK! Please see our contributing guide for more information.

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

tela-0.2.2.tar.gz (58.2 kB view details)

Uploaded Source

Built Distribution

tela-0.2.2-py3-none-any.whl (69.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: tela-0.2.2.tar.gz
  • Upload date:
  • Size: 58.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for tela-0.2.2.tar.gz
Algorithm Hash digest
SHA256 fb5370252d7d4abba908678a919f827fd5f074d32747329cda57a4ccd8a99bd8
MD5 0fc6a3c6d6c9336842b5c7963ab05a6b
BLAKE2b-256 bffa3843a534ec29b4a1f1d2eb83901f894b3bc954e7f082f9401814ac1328c7

See more details on using hashes here.

File details

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

File metadata

  • Download URL: tela-0.2.2-py3-none-any.whl
  • Upload date:
  • Size: 69.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for tela-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 8535a3e580efdbf98022226d723e27876d70287ea025a68bc897af9229a809a5
MD5 3325be3142752f609204c6f7e71ebbb9
BLAKE2b-256 f366921abe626c55373a95c9877869535cc529acda2351fde0cc20c7013d51cc

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