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

# Getting Started

> Make a first successful Tensormesh SDK request with the sync or async client.

This is the shortest SDK-first path to a working request.

The public inference surface exposes `chat.completions`, `models`, `completions`, `responses`, `tokenize`, `detokenize`, `health`, and `version`.

## 1. Install The Package

Prerequisite: Python `3.12` or newer.

For a published release:

```sh theme={null}
pip install tensormesh
```

## 2. Pick A Surface

* **Serverless inference**: use `client.inference.serverless`
* **Control Plane**: use `client.control_plane`

Inference usually uses an inference API key. On the default public serverless host, `models`, `health`, and `version` also work without one. Control Plane uses a bearer token.

For a first successful SDK request, start with serverless inference.

Model naming: serverless examples expect a serverless model name.

If you are coming from the CLI-managed flow, `gateway_api_key` is the stored inference API key used by the SDK as `inference_api_key`.

## 3. Get Credentials

* For a Control Plane bearer token, use the browser login flow in [CLI Authentication](/cli/guides/authentication), then use `tm auth print-token --yes-i-know` only in a controlled shell when you need to pass that token into SDK code.
* For an inference API key, either use the key your Tensormesh environment already issued to you, or create one through the authenticated Control Plane flow:

```sh theme={null}
tm auth login
USER_ID="$(tm --output json auth whoami | python3 -c 'import json,sys; print(json.load(sys.stdin)["user"]["id"])')"
tm users api-keys create --user-id "$USER_ID" --name sdk-key --yes
```

If your environment does not expose self-serve API key creation, ask your operator or admin for the exact inference API key to use.

## 4. Choose A Model Name

* Pass a serverless model name that is valid for the selected serverless host.
* If you have Control Plane access for the same Tensormesh environment, discover published serverless models with `tm billing pricing serverless list`.
* Use the returned `pricing[].model` value as the `model` argument.
* If you only have inference credentials, or you are targeting a different serverless host override, ask your operator or admin for the exact serverless `model` string for that host before sending the request.

If you do not already have a valid serverless model name, resolve it before using the serverless examples below. The supported paths are `tm billing pricing serverless list` for the same Tensormesh environment, or asking your operator or admin for the exact serverless `model` string.

## 5. First Sync Request

```python theme={null}
from tensormesh import Tensormesh
from tensormesh.types import ChatMessage

with Tensormesh(
    inference_api_key="YOUR_INFERENCE_API_KEY",
) as client:
    serverless_model_name = "YOUR_SERVERLESS_MODEL_NAME"
    completion = client.inference.serverless.chat.completions.create(
        model=serverless_model_name,
        messages=[ChatMessage(role="user", content="Say hello.")],
    )

print(completion.choices[0].message.content)
```

## 6. First Async Request

```python theme={null}
import asyncio

from tensormesh import AsyncTensormesh
from tensormesh.types import ChatMessage


async def main() -> None:
    async with AsyncTensormesh(
        inference_api_key="YOUR_INFERENCE_API_KEY",
    ) as client:
        serverless_model_name = "YOUR_SERVERLESS_MODEL_NAME"
        completion = await client.inference.serverless.chat.completions.create(
            model=serverless_model_name,
            messages=[ChatMessage(role="user", content="Say hello.")],
        )
        print(completion.choices[0].message.content)


asyncio.run(main())
```

## 7. First Control-Plane Request

```python theme={null}
from tensormesh import Tensormesh

with Tensormesh(control_plane_token="YOUR_CONTROL_PLANE_TOKEN") as client:
    profile = client.control_plane.users.get_auth_profile()

print(profile.display_name)
```

## Next Steps

* If you are deciding which credentials and base URLs to use, continue with [Auth And Config](/sdk/guides/auth-and-config).
* If you want chat completions plus the other verified serverless endpoints, continue with [Inference](/sdk/guides/inference).
* If you are migrating an existing OpenAI or Fireworks chat integration, continue with [Migration From OpenAI And Fireworks](/sdk/guides/migration-from-openai-fireworks).
* If you want models, billing, users, or support examples, continue with [Control Plane](/sdk/guides/control-plane).
* If you want the CLI operator path for Control Plane tasks, continue with [Control Plane Workflows](/cli/guides/control-plane-workflows).

## Related Reference

* [Raw Inference API Reference](/api-reference)
* [Control Plane API Reference](/tensormesh-api)
* [`tm billing pricing serverless list`](/cli/reference/billing/pricing/serverless/list)

Use the **Control Plane API** tab in the docs navigation for generated Control Plane reference.
