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

# Create Session

> Create a new session to group inference results.

## Returns

Returns a [Session](/concepts/product/version/session) object.

## Example

```python theme={"system"}
session = galtea.sessions.create(version_id=version_id, test_case_id=test_case_id, is_production=False)
```

## Parameters

<ResponseField name="version_id" type="string" optional>
  The ID of the version to associate with this session.

  <Note>Provide `version_id` or `product_id` (at least one). If both are given, `version_id` wins and `product_id` is ignored. Prefer `version_id` when you already have a specific version to attach to.</Note>
</ResponseField>

<ResponseField name="product_id" type="string" optional>
  The ID of the product to associate with this session, as an alternative to `version_id`. The API resolves the product's latest version, or creates a default one if the product has none yet.

  <Note>Provide `version_id` or `product_id` (at least one). If both are given, `version_id` wins and `product_id` is ignored.</Note>
</ResponseField>

<ResponseField name="test_case_id" type="string" optional>
  The ID of a test case. Forbidden when `is_production=True`. Sessions backed by a test case derive their `context` from the test case rather than the request.
</ResponseField>

<ResponseField name="custom_id" type="string" optional>
  A client-provided custom ID for the session.

  <Note>
    This is useful to associate sessions in the Galtea platform with those in your application.
  </Note>
</ResponseField>

<ResponseField name="context" type="string" optional>
  The context provided to the AI product during the session. Forbidden when `test_case_id` is set (it would be derived from the test case).
</ResponseField>

<ResponseField name="is_production" type="boolean" optional>
  A flag to indicate if the session represents real production traffic. When omitted, the API derives it from `test_case_id` presence: no test case means production. A non-production session no longer requires a `test_case_id` — externally ingested sessions (e.g. imported traces) may be classified as development data without being linked to a test case.
</ResponseField>

<ResponseField name="metadata" type="object" optional>
  Arbitrary key/value metadata to attach to the session at creation time. Omit it to send no `metadata`. This is the same metadata you can later set with [Update Session](/sdk/api/session/update).
</ResponseField>
