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

# Artifact and Output Exports

> Configure prediction, training table, embedding, and model artifact exports with the Kumo SDK

Kumo SDK jobs can write several types of outputs outside the Kumo platform:

* batch prediction scores;
* entity embeddings generated during prediction;
* generated training tables;
* model artifacts for online serving bundles.

The export APIs use explicit configuration objects so production jobs can choose the destination connector, table name, write mode, and metadata columns.

## Batch prediction outputs

Pass `OutputConfig` to `trainer.predict()` to write predictions and/or embeddings to a destination connector.

```python theme={null}
import kumoai as kumo
from kumoai.artifact_export.config import OutputConfig

output_config = OutputConfig(
    output_types={"predictions", "embeddings"},
    output_connector=connector,
    output_table_name="kumo_predictions",
)

prediction_job = trainer.predict(
    graph=graph,
    prediction_table=pquery.generate_prediction_table(non_blocking=True),
    training_job_id=training_job.job_id,
    output_config=output_config,
    non_blocking=False,
)

print(prediction_job.summary())
```

`output_types` controls which artifacts are written:

| Output type   | Description                                                                                          |
| ------------- | ---------------------------------------------------------------------------------------------------- |
| `predictions` | Scored prediction results for the generated prediction table                                         |
| `embeddings`  | Entity embeddings that can be used for downstream retrieval, analysis, or online serving preparation |

If `output_connector` is omitted, Kumo produces a local-download output instead of writing to an external destination.

## Destination connectors and table names

`output_connector` is any supported SDK connector that Kumo can write to for your deployment. `output_table_name` identifies the output location in that connector.

```python theme={null}
snowflake_output = OutputConfig(
    output_types={"predictions"},
    output_connector=snowflake_connector,
    output_table_name="KUMO_PREDICTIONS",
)

bigquery_output = OutputConfig(
    output_types={"predictions"},
    output_connector=bigquery_connector,
    output_table_name="kumo_predictions",
)
```

For Databricks output connectors, pass a `(schema, table)` tuple for the destination table.

```python theme={null}
databricks_output = OutputConfig(
    output_types={"predictions"},
    output_connector=databricks_connector,
    output_table_name=("analytics", "kumo_predictions"),
)
```

## Metadata columns

Add metadata columns to prediction output with `output_metadata_fields`.

```python theme={null}
from kumoapi.jobs import MetadataField

output_config = OutputConfig(
    output_types={"predictions"},
    output_connector=snowflake_connector,
    output_table_name="KUMO_PREDICTIONS",
    output_metadata_fields=[
        MetadataField.JOB_TIMESTAMP,
        MetadataField.ANCHOR_TIMESTAMP,
    ],
)
```

`JOB_TIMESTAMP` records when the job was run. `ANCHOR_TIMESTAMP` records the prediction anchor time for temporal prediction tasks; requesting it for a non-temporal prediction task raises an error.

## Append versus overwrite

Some connector types support connector-specific write modes. Use `BigQueryOutputConfig` or `SnowflakeConnectorConfig` with `connector_specific_config`.

```python theme={null}
from kumoapi.jobs import WriteMode
from kumoai.artifact_export.config import (
    BigQueryOutputConfig,
    OutputConfig,
    SnowflakeConnectorConfig,
)

bigquery_output = OutputConfig(
    output_types={"predictions"},
    output_connector=bigquery_connector,
    output_table_name="kumo_predictions",
    connector_specific_config=BigQueryOutputConfig(
        write_mode=WriteMode.APPEND,
    ),
)

snowflake_output = OutputConfig(
    output_types={"predictions"},
    output_connector=snowflake_connector,
    output_table_name="KUMO_PREDICTIONS",
    connector_specific_config=SnowflakeConnectorConfig(
        write_mode=WriteMode.OVERWRITE,
    ),
)
```

When appending to BigQuery, include `MetadataField.JOB_TIMESTAMP` so downstream consumers can distinguish runs.

<Warning>
  Connector-specific configs are validated against the connector type. Passing a Snowflake config for a BigQuery connector, or passing connector-specific config to a connector type that does not support it, raises a `ValueError`.
</Warning>

## Export generated training tables

Use `TrainingTableExportConfig` when you need to persist the full generated training table for inspection, governance, or downstream reuse.

```python theme={null}
from kumoai.artifact_export.config import TrainingTableExportConfig

training_table = pquery.generate_training_table(non_blocking=False)

export_config = TrainingTableExportConfig(
    output_types={"training_table"},
    output_connector=snowflake_connector,
    output_table_name="KUMO_TRAINING_TABLE",
)

export_job = training_table.export(export_config, non_blocking=True)
export_job.attach()
```

`TrainingTableExportConfig` requires `output_types={"training_table"}`, an `output_connector`, and an `output_table_name`. Prediction metadata fields are not supported for training table exports. For BigQuery and Snowflake destinations, you can also use `connector_specific_config` to set the connector-specific write mode.

## Export model artifacts for online serving

`export_model()` creates a model artifact export job. It bundles the online-serving model directory with embeddings from a batch prediction job and copies the bundle to the output path in `ModelOutputConfig`.

```python theme={null}
from kumoai.trainer import ModelOutputConfig, export_model

model_output = ModelOutputConfig(
    training_job_id=training_job.job_id,
    batch_prediction_job_id=prediction_job.job_id,
    output_path="s3://my-bucket/kumo/serving-bundles/churn-model/",
)

export_job = export_model(model_output, non_blocking=True)
print(export_job.id)
print(export_job.status())

export_result = export_job.attach()
print(export_result.job_id)
```

Set `non_blocking=False` to wait for completion immediately.

```python theme={null}
export_result = export_model(model_output, non_blocking=False)
```

## Monitoring export jobs

`export_model(..., non_blocking=True)` returns an `ArtifactExportJob`. Use the same future-style pattern as training and prediction jobs.

```python theme={null}
export_job = export_model(model_output, non_blocking=True)

print(export_job.status())
export_job.attach()      # watch progress until complete
result = export_job.result()

# Cancel if the job no longer needs to run.
export_job.cancel()
```

If an export job finishes in a failed or cancelled state, `result()` raises an error.

## Production tips

* Keep output table names deterministic so orchestration systems can find the latest run.
* Include run metadata columns when appending to shared prediction tables.
* Use separate output locations for predictions and embeddings if they have different downstream consumers.
* Export model artifacts only after the training and embedding-producing prediction jobs have completed successfully.
