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

# Artifacts

> List, parse, download and stream remote workflow outputs through explicit byte paths.

export const RemoteContract = () => <Warning>
    <strong>Preview surface.</strong> The root package types the intended
    workflow HTTP and SSE API. The reference engine does not ship a compatible
    workflow service today. Do not point it at the stable resident firer or
    <code>nika model serve</code>.
  </Warning>;

<RemoteContract />

Artifact format is part of the contract. Choose text, JSON, bytes or a stream
instead of forcing every output through one convenience method.

## Inspect before download

```ts theme={"system"}
const artifacts = await nika.jobs.artifacts(job_id)

for (const artifact of artifacts) {
  console.log(
    artifact.name,
    artifact.size,
    artifact.format,
    artifact.content_type,
  )
}
```

## Pick the representation

<CodeGroup>
  ```ts Text theme={"system"}
  const markdown = await nika.jobs.artifact(job_id, 'report.md')
  ```

  ```ts JSON theme={"system"}
  const result = await nika.jobs.artifactJson<Result>(
    job_id,
    'result.json',
  )
  ```

  ```ts Bytes theme={"system"}
  const image = await nika.jobs.artifactBinary(job_id, 'cover.png')
  ```

  ```ts Stream theme={"system"}
  const source = await nika.jobs.artifactStream(job_id, 'dataset.csv')
  await source.pipeTo(destination)
  ```
</CodeGroup>

`artifactStream()` keeps large outputs out of the heap and preserves platform
backpressure.

## Convenience collection

```ts theme={"system"}
const outputs = await nika.jobs.runAndCollect(
  'research.nika.yaml',
  { topic: 'workflow engines' },
)
```

The convenience method waits for completion, lists artifacts and downloads
non-binary outputs in bounded batches. It deliberately skips binary artifacts.

<Warning>
  Do not use `runAndCollect()` as an unbounded data-export path. Inspect sizes
  and use streams when an output can grow with user input.
</Warning>

## Continue

<CardGroup cols={2}>
  <Card title="Jobs" icon="list-check" href="/sdk/remote/jobs">
    Own the lifecycle that produced the files.
  </Card>

  <Card title="SSE streaming" icon="wave-pulse" href="/sdk/remote/streaming">
    React to artifact-written events.
  </Card>

  <Card title="Security" icon="shield" href="/sdk/operations/security">
    Govern output destinations and retention.
  </Card>

  <Card title="Method index" icon="list" href="/sdk/reference/methods">
    Compare every artifact method.
  </Card>
</CardGroup>
