Tela SDK for JavaScript
    Preparing search index...

    Class TelaSDK

    The main class for interacting with the Tela API.

    Provides methods to access various Tela API resources.

    const tela = new TelaSDK({ apiKey: 'your-api-key' });
    const completion = await tela.completions.create({
    canvasId: "your-canvas-id",
    messages: [{ role: "user", content: "Hello!" }],
    });

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    baseURL: string
    canvas: {
        get: <
            TInput extends
                | Record<string, unknown>
                | ZodType<unknown, unknown, $ZodTypeInternals<unknown, unknown>> = Record<
                string,
                unknown,
            >,
            TOutput extends
                | Record<string, unknown>
                | ZodType<unknown, unknown, $ZodTypeInternals<unknown, unknown>> = Record<
                string,
                unknown,
            >,
        >(
            options: CanvasGetOptions<TInput, TOutput>,
        ) => Promise<Canvas<TInput, TOutput>>;
    } = ...

    Retrieves a canvas by its ID, version ID, or application ID. Validates input and output schemas if provided via schema builder functions.

    Options for retrieving the canvas.

    A promise resolving to a Canvas instance.

    // Get canvas by ID with schemas
    const canvas = await tela.canvas.get({
    id: 'canvas-id',
    input: schema => schema.object({
    query: schema.string()
    }),
    output: schema => schema.object({
    response: schema.string()
    })
    });

    // Get canvas by application ID
    const canvas = await tela.canvas.get({
    applicationId: 'app-id'
    });

    // Execute the canvas
    const execution = await canvas.execute({ query: 'Hello' });
    const result = await execution.result;
    createFile: {
        (file: string | Blob | File, options?: BaseTelaFileOptions): TelaFile;
        (
            file: Uint8Array | ReadableStream<any>,
            options: TelaFileOptionsWithMimeType,
        ): TelaFile;
    } = ...

    Creates a new TelaFile instance from the provided file input.

    The file input to create a TelaFile instance from.

    A new TelaFile instance.

    fetch: typeof fetch
    maxRetries: number
    timeout: number
    workstation: {
        get: <
            TInput extends
                | Record<string, unknown>
                | ZodType<unknown, unknown, $ZodTypeInternals<unknown, unknown>> = Record<
                string,
                unknown,
            >,
            TOutput extends
                | Record<string, unknown>
                | ZodType<unknown, unknown, $ZodTypeInternals<unknown, unknown>> = Record<
                string,
                unknown,
            >,
        >(
            options: WorkstationGetOptions<TInput, TOutput>,
        ) => Promise<Workstation<TInput, TOutput>>;
    } = ...
    APIError: typeof APIError = Errors.APIError

    Thrown when an API request fails.

    AuthenticationError: typeof AuthenticationError = Errors.AuthenticationError

    Thrown when authentication fails (e.g., invalid API key).

    AuthorizationError: typeof AuthorizationError = Errors.AuthorizationError

    Thrown when the authenticated user doesn't have permission for the requested operation.

    BadRequestError: typeof BadRequestError = Errors.BadRequestError

    Thrown when the API returns a 400 Bad Request error.

    ConflictApiKeyAndJWTError: typeof ConflictApiKeyAndJWTError = Errors.ConflictApiKeyAndJWTError

    Thrown when both an API key and a JWT are provided.

    ConflictError: typeof ConflictError = Errors.ConflictError

    Thrown when there's a conflict with the current state of the resource.

    ConnectionError: typeof ConnectionError = Errors.ConnectionError

    Thrown when there's a network connection error.

    ConnectionTimeout: typeof ConnectionTimeout = Errors.ConnectionTimeout

    Thrown when a request times out.

    DEFAULT_TIMEOUT: number = 0
    EmptyFileError: typeof EmptyFileError = Errors.EmptyFileError

    Thrown when attempting to upload an empty file.

    ExecutionFailedError: typeof ExecutionFailedError = Errors.ExecutionFailedError

    Thrown when a canvas execution fails on the server.

    FileUploadError: typeof FileUploadError = Errors.FileUploadError

    Thrown when there's an error during file upload.

    InternalServerError: typeof InternalServerError = Errors.InternalServerError

    Thrown when an unexpected server error occurs.

    InvalidFileURL: typeof InvalidFileURL = Errors.InvalidFileURL

    Thrown when an invalid file URL is provided.

    MissingApiKeyOrJWTError: typeof MissingApiKeyOrJWTError = Errors.MissingApiKeyOrJWTError

    Thrown when neither an API key nor a JWT is provided.

    NotFoundError: typeof NotFoundError = Errors.NotFoundError

    Thrown when the requested resource is not found.

    RateLimitError: typeof RateLimitError = Errors.RateLimitError

    Thrown when the API rate limit is exceeded.

    TaskFailedError: typeof TaskFailedError = Errors.TaskFailedError

    Thrown when a workstation task fails on the server.

    TelaSDK: typeof TelaSDK = ...
    UnprocessableEntityError: typeof UnprocessableEntityError = Errors.UnprocessableEntityError

    Thrown when the request is well-formed but unable to be processed due to semantic errors.

    UserAbortError: typeof UserAbortError = Errors.UserAbortError

    Thrown when a request is aborted by the user.

    Accessors

    • get authToken(): string

      Returns string

    Methods

    • Type Parameters

      • Req

      Parameters

      • path: string
      • query: Req | null | undefined

      Returns string

    • Parameters

      • Optionalopts: Record<string, string>

      Returns Headers

    • Parameters

      • url: string
      • _options: RequestInit
      • timeout: number
      • controller: AbortController

      Returns Promise<Response>

    post

    • Parameters

      • query: Record<string, unknown>

      Returns string