Skip to main content

Quickstart


Quickstart

Hundreds of fast and cheap AI image generation APIs for 10000+ models. Fastest generation in just 2s, Pay-As-You-Go, a minimum of $0.0015 for each image, you can add your own models and avoid GPU maintenance.

1. Visit novita.aiopen in new window

2. Click the "Log In" button in the top navigation bar

  • At present, we exclusively offer both Google login and Github login authentication method.

3. Create an API key

  • Currently authentication to the API is performed via Bearer Token in the request header (e.g. -H "Authorization: Bearer ***").

  • We'll provision a new API key Hereopen in new window.

novita.ai API
  • You can create your own key with the Add new key.

4. Top up your account

  • In your account dashboard, you will see a Credit section. We give each logged-in user 10 free chances to generate a picture. Hereopen in new window you will find the historical usage data of your account.
novita.ai API
novita.ai API

5. Get your balance

  • This interface facilitates user information queries, primarily focusing on functions available to the user and their account balance.

Request:

curl \
-X GET https://api.novita.ai/v3/user \
-H "Authorization: Bearer {{{{key}}}}"

Response:

{
  "allow_features": [
    "upload_model"
  ],
  "credit_balance": 755832
}

The allow_features in response indicates the features that the user is allowed to use. The credit_balance indicates the remaining credit balance of the user, which is calculated as Credit * 10000.(Credit was in the top right corner of the official website)

6. Configure S3 address (Optional)

Please change your AWS S3 Bucket Policy configuration to the following format at first. (Replace ${BucketName} with the real target bucket name):

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Principal": {
        "CanonicalUser": "e98cde8d11ec7c03ac08688f1a933b08b0f0f7746b21c4f2e7b2c8202cc0532f"
      },
      "Action": [
        "s3:PutObject",
        "s3:PutObjectAcl"
      ],
      "Resource": "arn:aws:s3:::${BucketName}/*"
    }
  ]
}

6.1 For V3 endpoints

  • For V3 endpoints, novita.ai provides the custom_storage parameter in the request body, allowing you to configure the S3 address associated with your account for storing generated images. If no S3 address is specified, the system will automatically store the generated images in our default S3 bucket.

Configure the AWS S3 address of your account:

Request:

curl --location 'https://api.novita.ai/v3/async/txt2img' \
--header 'Authorization: Bearer {{key}}' \
--header 'Content-Type: application/json' \
--data '{
  "extra": {
    "response_image_type": "jpeg",
    "custom_storage": {
      "aws_s3": {
        "region": "us-east-2",
        "bucket": "test_bucket",
        "path": "/"
      }
    },
    "enterprise_plan": {
      "enabled": false
    }
  },
  "request": {
        "prompt": "a cute dog",
        "model_name": "realisticVisionV51_v51VAE_94301.safetensors",
        "negative_prompt": "nsfw, bottle,bad face",
        "width": 512,
        "height": 384,
        "image_num": 2,
        "steps": 20,
        "seed": 123,
        "clip_skip": 1,
        "sampler_name": "Euler a",
        "guidance_scale": 7.5
  }
}'

6.2 For V2 endpoints (Deprecated)

  • For V2 endpoints, novita.ai offers an endpoint to configure the S3 address associated with your account, facilitating the storage of generated images. In the event that no S3 address is specified, the system will automatically store the generated images in our default S3 bucket.

Configure the AWS S3 address of your account:

Request:

curl \
-X POST https://api.novita.ai/v2/config \
-H "Authorization: Bearer {{key}}" \
-H "Content-Type: application/json" \
-d '{"s3_region":"ap-southeast-1","s3_bucket":"stars-test","s3_path":"/test"}'

Response:

{
  "code": 0,
  "msg": ""
}

Get current AWS S3 address of your account:

Request:

curl --location --request GET 'http://api.novita.ai/v2/config' \
--header 'Authorization: Bearer {{key}}'

Response:

{
    "code": 0,
    "msg": "",
    "data": {
        "region": "ap-southeast-1",
        "bucket": "stars-test",
        "path": "/test/"
    }
}

Delete current AWS S3 address of your account, after the call is successful, it will be temporarily stored in novita.ai by default.

Request:

curl --location --request DELETE 'http://api.novita.ai/v2/config' \
--header 'Authorization: Bearer {{key}}'

Response:

{
    "code": 0,
    "msg": ""
}

7. Explore more

Check out the following guides to see what else you can do with novita.ai:

If you encounter any questions, please reach out to us on discord.open in new window