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 via npm, yarn, or pnpm:

pip install tela_sdk_python

Usage

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

from tela_sdk_python 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_sdk_python 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_sdk_python 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_sdk_python 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_sdk_python 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.1.0.tar.gz (58.6 kB view details)

Uploaded Source

Built Distribution

tela-0.1.0-py3-none-any.whl (69.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: tela-0.1.0.tar.gz
  • Upload date:
  • Size: 58.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.12.2 Darwin/24.0.0

File hashes

Hashes for tela-0.1.0.tar.gz
Algorithm Hash digest
SHA256 30188aee4cbd27f9c1e265f54d6b6b34d7133633858453e450bf793d90f6e021
MD5 0bb6cd89771415ecf70352df73b2f50b
BLAKE2b-256 6b89d93ff4a6df1fb828c6b3f01ee4a302ac73ffea72e7ffa63fea574a580164

See more details on using hashes here.

File details

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

File metadata

  • Download URL: tela-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 69.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.12.2 Darwin/24.0.0

File hashes

Hashes for tela-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0505092989c402a12c7a9d855466cbd29d5d9d24243be7a28b09c54b81f99937
MD5 fc0ef4f400207f74ccd2c6ea2d0565c9
BLAKE2b-256 b1f7d755ea891b329dbb3f99359d7bf6898b5f940ad96bdd8689aa42df3bd871

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