Skip to content

Create Deployments

Learn how to create a new deployment using either the Nosana HTTP API or the TypeScript SDK.

Prerequisites

Before creating deployments, ensure you have:

  • API Key: A valid Nosana API key. See the API key guide.
  • Credit Balance: Sufficient credit balance on your Nosana account to run deployments.
  • Job Definition: A valid job definition describing the container workload.

What you configure

When creating a deployment, you specify:

  • A unique name for your deployment
  • The target market (GPU market address)
  • Deployment configuration: timeout, replicas, strategy
  • The job definition (container image, commands, operations)

For all available fields, see Deployment Options. You can find GPU markets here.

Create a Deployment

ts
import { createNosanaClient } from '@nosana/kit';

const client = createNosanaClient('mainnet', {
  api: {
    apiKey: process.env.NOSANA_API_KEY,
  },
});

async function createDeployment() {
  const deployment = await client.api.deployments.create({
    name: 'Hello World',
    market: '7AtiXMSH6R1jjBxrcYjehCkkSF7zvYWte63gwEDBcGHq',
    timeout: 60, // minutes
    replicas: 1,
    strategy: 'SIMPLE',
    job_definition: {
      version: '0.1',
      type: 'container',
      meta: {
        trigger: 'api',
      },
      ops: [
        {
          type: 'container/run',
          id: 'hello-world',
          args: {
            cmd: 'for i in `seq 1 30`; do echo $i; sleep 1; done',
            image: 'ubuntu',
          },
        },
      ],
    },
  });
}

The response contains the created deployment, including its id, which you will need to start or manage it.

Start a Deployment

New deployments are created in a draft state and must be explicitly started:

ts
async function startDeployment(id: string) {
  const deployment = await client.deployments.get(id);
  await deployment.start();
}

Replace <deployment_id> with the id returned from the create call.