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

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.0.tar.gz (58.6 kB view details)

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: tela-0.2.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.2.0.tar.gz
Algorithm Hash digest
SHA256 b3ba01210f34dd5cc2df3be3fed3355b8ac44389a9860d3e0e2d4d004c942ad1
MD5 3e3a4cfc3088a78b7a65953349f74e57
BLAKE2b-256 62525d974f21e25e0e590ca83be4972654d35d9a4ddd690cfd3c2dbcf7490400

See more details on using hashes here.

File details

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

File metadata

  • Download URL: tela-0.2.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.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 425c58cffd4664e88cd000b9026f3dfe1654f15a81e8c6d0cda88343d4260ad0
MD5 d09e6be6c8ae4fe7b02056921c24a5aa
BLAKE2b-256 6dc26ca5141f14d137eb1f5f68ee5ebd49d4c431cae0ec01acb48a52ba5132b3

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