> ## Documentation Index
> Fetch the complete documentation index at: https://docs.tensorlake.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Introduction

> Add serverless orchestration to any agent

Orchestrate is a serverless runtime for adding data orchestration capabilities to Agents. You can build orchestration APIs without deploying containers, workers or queues. Functions starts running when they are called and scale down to zero after finishing work.

Some use cases are -

1. Creating multi-stage tools that needs to be retried until they complete.
2. Data ingestion worklfow APIs.
3. Scale out processing using distributed map and reduce.

```python theme={null}
from tensorlake.applications import application, function

@function()
def summarize(doc: str) -> int:
   summary = call_llm(doc)
   return summary

@function()
def summarize_files(docs: List[str]) -> List[str]:
    summaries = docs.map(summarize)
    return summaries
```

1. Tensorlake functions are a unit of compute which is executed in a sandbox and retried based on a user provided retry policy.

2. Functions decorated with `@applications` becomes callable from external systems and exposed as HTTP APIs.

3. Function calls are automatically queued durably when they are called when there is not enough compute to handle the requests.

4. Each function’s inputs and outputs are check-pointed durably so they can be retried.

5. Every function can have different resource asks, making it possible to allocate more resources to functions which are more compute or memory intensive.

### Quickstart

Let's build a simple application that greets a user by name.

<Steps>
  <Step title="Install the Tensorlake SDK">
    ```bash theme={null}
    pip install tensorlake
    ```
  </Step>

  <Step title="Get an API Key">
    You can get an [API key](/platform/authentication#api-keys) from the Tensorlake Dashboard.

    ```bash theme={null}
    export TENSORLAKE_API_KEY=<your-api-key>
    ```
  </Step>

  <Step title="Create an application">
    Applications are defined by Python functions. Let's start with a template, that greets a user by name.

    ```bash theme={null}
    tl new hello_world
    ```

    This creates a file named `hello_world/hello_world.py` with the following content:

    ```python hello_world.py theme={null}
    from tensorlake.applications import application, function
    @application()
    @function()
    def greet(name: str) -> str:
        return f"Hello, {name}!"
    ```
  </Step>

  <Step title="Deploy It">
    Deploy your application referencing your application's source file.

    ```bash theme={null}
    tl deploy hello_world/hello_world.py
    ```
  </Step>
</Steps>

## Invoke Orchestrate Functions

Orchestrate endpoints can be invoked using HTTP requests or the Python SDK.

### HTTP Endpoint

```
https://api.tensorlake.ai/applications/<app_name>
```

<Steps>
  <Step title="Make a request">
    <CodeGroup>
      ```bash bash theme={null}
      curl https://api.tensorlake.ai/applications/hello_world \
      -H "Authorization: Bearer $TENSORLAKE_API_KEY" \
      --json '"John"'
      # {"request_id":"beae8736ece31ef9"}
      ```

      ```python python theme={null}
      from tensorlake.applications import run_remote_application, Request

      request: Request = run_remote_application(greet, 'John')
      print(request.id)

      # "beae8736ece31ef9"
      ```
    </CodeGroup>

    This will return a request ID that you can use to track the progress of your request.
  </Step>

  <Step title="Check progress">
    Requests may run seconds to hours depending on your workload.

    <CodeGroup>
      ```bash bash theme={null}
      curl -X GET https://api.tensorlake.ai/applications/hello_world/requests/{request_id} \
      -H "Authorization: Bearer $TENSORLAKE_API_KEY"
      # {
      #   "id":"B0IwzHibTTfn5mCXHPGsu",
      #   "outcome":"success",
      #   "failure_reason":null,
      #   "request_error":null,
      #   .... other fields ...
      #}
      ```

      ```python python theme={null}
      # You don't need to poll for request completion. Retrieving the output will wait for the request to complete.
      ```
    </CodeGroup>

    The `outcome` field will be `success` or `failure` depending on whether the request completed successfully. It will be null if the request is still in progress.
  </Step>

  <Step title="Get the output">
    <CodeGroup>
      ```bash bash theme={null}
      curl -X GET https://api.tensorlake.ai/applications/hello_world/requests/{request_id}/output \
      -H "Authorization: Bearer $TENSORLAKE_API_KEY"
      # "Hello, John!"
      ```

      ```python python theme={null}
      from tensorlake.applications import run_remote_application, Request

      request: Request = run_remote_application(greet, 'John')
      output: str = request.output()

      print(output)
      # "Hello, John!"
      ```
    </CodeGroup>
  </Step>
</Steps>

## Testing Locally

Tensorlake Applications can run locally on your laptop. You can run them like regular python scripts.

```python hello_world.py theme={null}
# At the end of the file
from tensorlake.applications import run_local_application, Request
if __name__ == "__main__":
    request: Request = run_local_application(greet, 'John')
    output: str = request.output()
    print(output)
# "Hello, John!"
```

Deploying agents which starts complex workflows, or multi-stage tool calls requires building complex distributed systems with queues, workers or orchestration
engines. It takes away time from focusing and building the agentic logic. Orchestrate helps to solve this problem by letting you write orchestration
endpoints and solves the coordination of functions, retries and autoscaling.

## Examples

<CardGroup cols={2}>
  <Card title="Deep Research Agent" icon="magnifying-glass" href="/examples/agentic-applications/deep-research">
    Multi-agent research pipeline with parallel web search and report synthesis using OpenAI Agents SDK.
  </Card>

  <Card title="Code Interpreter" icon="code" href="/examples/agentic-applications/code-interpreter">
    Execute LLM-generated code safely in isolated containers with data science libraries.
  </Card>

  <Card title="Agent with Tool Calling" icon="screwdriver-wrench" href="/examples/agentic-applications/agent-with-tools">
    Claude agentic loop that chains tool calls, each running in its own isolated container.
  </Card>

  <Card title="Personal Finance Manager" icon="wallet" href="/examples/agentic-applications/personal-finance-manager">
    Parse bank statements, categorize transactions, and answer spending questions with Claude.
  </Card>

  <Card title="Web Scraper" icon="spider-web" href="/examples/agentic-applications/web-scraper">
    Serverless web crawler that scrapes websites N levels deep using headless Chrome.
  </Card>

  <Card title="Weather Agent" icon="cloud-sun" href="/examples/agentic-applications/weather-agent">
    Conversational weather agent powered by Claude, deployed as an HTTP API.
  </Card>
</CardGroup>

## Next Steps

<Card title="Deploy Your First Agent" icon="rocket" href="/applications/quickstart">
  Follow our quick start guide to build and deploy a serverless agentic code interpreter in under 5 minutes.
</Card>
