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

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: tela-0.2.1.tar.gz
  • Upload date:
  • Size: 58.5 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.1.tar.gz
Algorithm Hash digest
SHA256 c509f8fa849ff487259eb92b6b8d22e1ce8007fd3815d37f3afa69aa169417bc
MD5 3ab1e7615e4f081d8550fa1f7deaa6fd
BLAKE2b-256 e2ab797aa35e2e6b587e820b3082dbf44b8c41fa8bc9e27021bb8a477a89ea1a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: tela-0.2.1-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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 94178d882930c2eb24d03269297136b4e0d1a554fcaf1f825901914c8b8364b6
MD5 4be9e284baa28fc7ea1b40ed69a184b2
BLAKE2b-256 dceeef042b0ba68b23dbe0370ebb422be9a08a91f87f018bf3cb187c4f8cdc55

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