### Civitai Link: Following Connection Flow - Client (Diagram) Source: https://developer.civitai.com/docs/link Describes the client-side process for re-establishing a connection to an existing Civitai Link instance after the initial setup. ```mermaid Client->Server: GET LinkInstances Note over Server: Finds LinkInstances for User Server->Client: Returns LinkInstances Note over Client: Selects LinkInstance Client->Server: Join room with LinkKey ``` -------------------------------- ### Install Civitai Node.js Client Source: https://developer.civitai.com/docs/api/javascript-sdk Installs the Civitai Node.js client package using npm. This is the first step before using the client in your project. ```bash npm install civitai ``` -------------------------------- ### Install Civitai JavaScript SDK Source: https://developer.civitai.com/docs/getting-started/javascript-sdk Installs the Civitai JavaScript SDK using npm. This is the first step to integrating Civitai's image generation capabilities into your project. ```bash npm install civitai ``` -------------------------------- ### Install Dependencies with npm Source: https://developer.civitai.com/docs/api/javascript-sdk Installs project dependencies using npm. Ensure Node.js and npm are installed and configured according to package.json specifications. ```bash npm install ``` -------------------------------- ### Install Civitai Python Client Source: https://developer.civitai.com/docs/api/python-sdk Installs the Civitai Python client library using pip. This is the first step to integrate Civitai's generator into your Python projects. ```bash pip install civitai-py ``` -------------------------------- ### Room Management and Communication Source: https://developer.civitai.com/docs/link APIs and protocols for joining rooms, managing connections, and sending/receiving commands between the client, extension, and server. ```APIDOC ## POST /JoinRoom ### Description Allows a client or extension to join a specific room using a provided `LinkKey`. The server upgrades the `LinkKey` upon successful join and moves the connection to an upgrade room. ### Method POST ### Endpoint `/JoinRoom` ### Parameters #### Request Body - **LinkKey** (string) - Required - The key obtained from `POST /LinkInstance` or stored by the extension. ### Request Example ```json { "LinkKey": "unique_link_key_123" } ``` ### Response #### Success Response (200) - **LinkKey** (string) - The upgraded `LinkKey` provided by the server. #### Response Example ```json { "LinkKey": "upgraded_link_key_789" } ``` --- ## WebSocket Communication ### Description After establishing a connection via `POST /JoinRoom`, communication for commands and status updates occurs within the established room, likely over a persistent connection like WebSockets. ### Method (Implicitly WebSocket) ### Endpoint (Within the joined room) ### Parameters #### Client to Extension - **Requests**: Client makes requests to the extension within the room. #### Extension to Server - **Join room with LinkKey**: Extension joins the room using the stored `LinkKey`. - **Send commands**: Extension sends commands to the server within the room. #### Server to Extension - **Gives new LinkKey**: Server provides a new `LinkKey` to the extension. - **Responds with status**: Server responds with status updates in the room. ### Request Example (Example of a command sent from client to extension, then to server) ```json // Client to Extension (example) { "command": "resources:add", "payload": { "resources": [ { "type": "lora", "hash": "sha256_hash_value", "name": "my_lora_model", "previewImage": "http://example.com/preview.png", "url": "http://example.com/lora.safetensors" } ] } } // Extension to Server (after processing client request) { "id": "uuid_for_request", "version": "1.0.0", "createdAt": "2023-10-27T10:00:00Z", "command": "resources:add", "payload": { "resources": [ { "type": "lora", "hash": "sha256_hash_value", "name": "my_lora_model", "previewImage": "http://example.com/preview.png", "url": "http://example.com/lora.safetensors" } ] } } ``` ### Response #### Success Response (Status within the room) - **Status updates**: Real-time feedback on command execution. #### Response Example ```json // Server to Extension (example) { "id": "uuid_for_request", "status": "processing", "resources": [ { "type": "lora", "hash": "sha256_hash_value", "status": "pending", "progress": 0 } ] } ``` ``` -------------------------------- ### Get Model Images Source: https://developer.civitai.com/docs/api/public-rest Retrieves images associated with a specific model, including image details, metadata, and URLs. This endpoint is useful for fetching generated images or examples related to a particular model. ```APIDOC ## GET /websites/developer_civitai/models/{modelId}/images ### Description Retrieves a list of images associated with a specific model. Each image object contains its URL, NSFW status, dimensions, hash, and detailed metadata including generation parameters like prompt, negative prompt, seed, sampler, CFG scale, and more. ### Method GET ### Endpoint /websites/developer_civitai/models/{modelId}/images #### Path Parameters * **modelId** (integer) - Required - The unique identifier of the model for which to retrieve images. ### Response #### Success Response (200) - **images** (array) - An array of image objects. - **url** (string) - The URL of the image. - **nsfw** (boolean) - Indicates if the image is marked as NSFW. - **width** (integer) - The width of the image in pixels. - **height** (integer) - The height of the image in pixels. - **hash** (string) - A hash identifier for the image. - **meta** (object) - Metadata associated with the image generation. - **ENSD** (string) - Undefined. - **Size** (string) - The resolution of the generated image (e.g., "512x512"). - **seed** (integer) - The seed value used for image generation. - **Score** (string) - User-defined score for the image. - **steps** (integer) - The number of diffusion steps used. - **prompt** (string) - The positive prompt used for generation. - **sampler** (string) - The sampler algorithm used (e.g., "DDIM"). - **Eta DDIM** (string) - The Eta value for DDIM sampler. - **cfgScale** (float) - The classifier-free guidance scale. - **resources** (array) - Undefined. - **Model hash** (string) - The hash of the model used for generation. - **Hires upscale** (string) - The Hires upscale factor. - **Hires upscaler** (string) - The Hires upscaler used. - **negativePrompt** (string) - The negative prompt used for generation. - **Denoising strength** (string) - The denoising strength value. - **downloadUrl** (string) - The URL to download the model associated with these images. #### Response Example ```json { "images": [ { "url": "https://imagecache.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/d91b46e7-7d69-43db-239d-412bdd8ed400/width=450/95908.jpeg", "nsfw": false, "width": 792, "height": 792, "hash": "UGF6CBnNI9xB~WxDs:RPVtaJofRQ00bwj@ad", "meta": { "ENSD": "31337", "Size": "512x512", "seed": 2355045759, "Score": "5.88", "steps": 30, "prompt": "21CharTurnerV2 character turnaround of young boy as a paperboy, cute adorable little kid, full body, standing, same outfit", "sampler": "DDIM", "Eta DDIM": "0.16", "cfgScale": 6.5, "resources": [], "Model hash": "5f8c744ab3", "Hires upscale": "1.55", "Hires upscaler": "Latent (nearest-exact)", "negativePrompt": "costume variations, outfit variations, sci-fi, tight clothes, skin tight, muscles., cartoon, 3d, (disfigured), (bad art), (deformed), (poorly drawn), (extra limbs), strange colours, blurry, boring, sketch, lacklustre, repetitive, cropped, hands, lowres, bad anatomy, bad hands, text, error, missing fingers, extra digit, fewer digits, cropped, worst quality, low quality, normal quality, jpeg artifacts, signature, watermark, username, blurry,bad anatomy , liquid body, malformed, mutated, bad proportions, uncoordinated body, unnatural body, disfigured, ugly, gross proportions ,mutation, disfigured, deformed, (mutation), (poorly drawn), wet, legs feet, cartoon, 3d, (disfigured), (bad art), (deformed), (poorly drawn), (extra limbs), strange colours, blurry, boring, sketch, lacklustre, repetitive, cropped, hands,", "Denoising strength": "0.7" } } ], "downloadUrl": "https://civitai.com/api/download/models/9857" } ``` ``` -------------------------------- ### Fetch Model Data via API (curl) Source: https://developer.civitai.com/docs/api/public-rest This example shows how to make a GET request to the Civitai API to retrieve details about a specific model. It specifies the model ID and includes necessary headers for the request. The response contains detailed information about the model, including its metadata, creator, tags, and versions. ```curl curl https://civitai.com/api/v1/models/1102 \ -H "Content-Type: application/json" \ -X GET ``` -------------------------------- ### Create Civitai Client for JavaScript SDK Source: https://developer.civitai.com/docs/getting-started/javascript-sdk Demonstrates how to initialize the Civitai client in JavaScript. Supports both ESM and CommonJS module formats. Requires an API token for authentication. ```javascript // ESM (where "type": module in package.json or using .mjs extension) import { Civitai } from "civitai"; // CommonJS (using .cjs extension) const Civitai = require("civitai"); ``` ```javascript const civitai = new Civitai({ auth: "YOUR_API_TOKEN", }); ``` -------------------------------- ### Civitai Link: First Connection Flow (Diagram) Source: https://developer.civitai.com/docs/link Illustrates the sequence of messages and actions during the initial connection between a client, server, and extension for establishing a Civitai Link. ```mermaid Client->Server: POST LinkInstance Note over Server: Generates LinkInstance Server->Client: Returns LinkKey Client->Server: Join room with LinkKey Client-->Extension: User copies over LinkKey Extension->Server: Join room\nwith LinkKey Note over Server: Upgrades LinkKey Note over Server: Moves to upgrade room Server->Extension: Gives new LinkKey Note over Extension: Stores new LinkKey Client->Extension: Makes requests in room Note over Extension: Perform actions Extension->Client: Responds with status in room Note over Server: On Disconnect notify room ``` -------------------------------- ### Link Instance Management Source: https://developer.civitai.com/docs/link APIs for establishing and managing the connection between a client and a Stable Diffusion instance using the Civitai Link service. ```APIDOC ## POST /LinkInstance ### Description Initiates a new link instance by sending a POST request to the server. The server generates a unique `LinkInstance` and returns a `LinkKey` to the client. ### Method POST ### Endpoint `/LinkInstance` ### Parameters #### Request Body - **None** ### Request Example ```json {} ``` ### Response #### Success Response (200) - **LinkKey** (string) - The unique key to establish a connection. #### Response Example ```json { "LinkKey": "unique_link_key_123" } ``` --- ## GET /LinkInstances ### Description Retrieves a list of available `LinkInstances` associated with the user. This is typically used by the client to select an existing instance to connect to. ### Method GET ### Endpoint `/LinkInstances` ### Parameters #### Query Parameters - **None** ### Request Example ``` None (GET request) ``` ### Response #### Success Response (200) - **LinkInstances** (array) - A list of available link instances. - **LinkKey** (string) - The unique key for each link instance. #### Response Example ```json { "LinkInstances": [ { "LinkKey": "unique_link_key_123" }, { "LinkKey": "another_link_key_456" } ] } ``` ``` -------------------------------- ### Get User ID using API Key - cURL Source: https://developer.civitai.com/docs/getting-started/faq Retrieve your user ID by making a GET request to the /me endpoint using your API key for authentication. This is useful for personalizing interactions with the Civitai API. ```shell curl --location 'https://civitai.com/api/v1/me' \ --header 'Authorization: Bearer ' ``` -------------------------------- ### Get First Image - cURL Request Source: https://developer.civitai.com/docs/api/public-rest This cURL command demonstrates how to request the first image from the Civitai API. It specifies the endpoint, sets the content type to JSON, and uses the GET method. The `limit=1` parameter is used to retrieve only a single image. ```shell curl https://civitai.com/api/v1/images?limit=1 \ -H "Content-Type: application/json" \ -X GET ``` -------------------------------- ### Create and Run Text-to-Image Job with JavaScript SDK Source: https://developer.civitai.com/docs/getting-started/javascript-sdk Shows how to configure and execute a text-to-image generation job using the Civitai JavaScript SDK. Includes defining prompts, negative prompts, scheduler, steps, and image dimensions. Jobs can be run immediately or in the background, with a 10-minute timeout. ```javascript import { Scheduler } from "civitai"; const input = { model: "urn:air:sd1:checkpoint:civitai:4201@130072", params: { prompt: "RAW photo, face portrait photo of 26 y.o woman, wearing black dress, happy face, hard shadows, cinematic shot, dramatic lighting", negativePrompt: "(deformed iris, deformed pupils, semi-realistic, cgi, 3d, render, sketch, cartoon, drawing, anime, mutated hands and fingers:1.4), (deformed, distorted, disfigured:1.3)", scheduler: Scheduler.EULER_A, steps: 20, cfgScale: 7, width: 512, height: 512, clipSkip: 2, }, }; ``` ```javascript const response = await civitai.image.fromText(input); ``` ```javascript const output = civitai.jobs.get(response.token); ``` ```javascript const response = await civitai.image.fromText(input, true); // Add true flag ``` -------------------------------- ### Get TextualInversion Models via API Source: https://developer.civitai.com/docs/api/public-rest This code snippet demonstrates how to make a GET request to the Civitai API to retrieve the first 3 TextualInversion models. It specifies the content type as JSON and sets a limit for the number of results. The response contains a list of models with detailed information. ```curl curl https://civitai.com/api/v1/models?limit=3&types=TextualInversion \ -H "Content-Type: application/json" \ -X GET ``` -------------------------------- ### Civitai Link: `resources:list` Request/Response (JSON) Source: https://developer.civitai.com/docs/link Specifies the request and response format for listing available resources of specified types on the Stable Diffusion instance via Civitai Link. ```json // Request { "id": "uuid", "types": [ "checkpoint", "lora", //... ] } // Response { "id": "uuid", "resources": [{ "type": "lora" | "checkpoint" ...; "hash": "sha256", "name": "name of file", "path": "optional path to file on fs" }] } ``` -------------------------------- ### GET /api/v1/tags Source: https://developer.civitai.com/docs/api/public-rest Retrieve a list of tags from Civitai. ```APIDOC ## GET /api/v1/tags ### Description Retrieves a list of tags available on the Civitai platform. ### Method GET ### Endpoint `https://civitai.com/api/v1/tags` ### Query Parameters #### Path Parameters * None #### Query Parameters *No specific query parameters are detailed in the provided text for this endpoint, but general parameters like `limit` and `page` might be applicable.* ``` -------------------------------- ### GET /api/v1/models Source: https://developer.civitai.com/docs/api/public-rest Retrieve a list of models from Civitai. ```APIDOC ## GET /api/v1/models ### Description Retrieves a list of models available on the Civitai platform. ### Method GET ### Endpoint `https://civitai.com/api/v1/models` ### Query Parameters #### Path Parameters * None #### Query Parameters *No specific query parameters are detailed in the provided text for this endpoint, but general parameters like `limit`, `page`, and `sort` might be applicable based on other endpoints.* ``` -------------------------------- ### Civitai Link: `resources:add` Request/Response (JSON) Source: https://developer.civitai.com/docs/link Defines the request and response structure for adding resources (like LoRAs or checkpoints) to the Stable Diffusion instance via Civitai Link. ```json // Request { "id": "uuid", "resources": [{ "type": "lora" | "checkpoint" ...; "hash": "sha256", "name": "name of file", "previewImage": "url to preview image", "url": "url to download if missing" }] } // Response { "id": "uuid", "resources": [{ //... props from request "status": "pending" | "processing" | "success" | "error" | "canceled", "progress": 0-100.00 }], "status": "pending" | "processing" | "success" | "error" } ``` -------------------------------- ### Get Model Version by ID (curl) Source: https://developer.civitai.com/docs/api/public-rest This snippet demonstrates how to retrieve detailed information about a specific model version from the Civitai API using a curl command. It specifies the GET request method and sets the Content-Type header to application/json. The response is a JSON object containing all metadata for the requested model version, including its files, images, and statistics. ```bash curl https://civitai.com/api/v1/model-versions/1318 \ -H "Content-Type: application/json" \ -X GET ``` -------------------------------- ### Create a Text-to-Image Job (Basic) Source: https://developer.civitai.com/docs/api/python-sdk Defines the input parameters for a text-to-image generation job using the Civitai SDK. This includes the model URN, prompt, negative prompt, scheduler, steps, CFG scale, and image dimensions. ```python input = { "model": "urn:air:sd1:checkpoint:civitai:4201@130072", "params": { "prompt": "RAW photo, face portrait photo of 26 y.o woman, wearing black dress, happy face, hard shadows, cinematic shot, dramatic lighting", "negativePrompt": "(deformed iris, deformed pupils, semi-realistic, cgi, 3d, render, sketch, cartoon, drawing, anime, mutated hands and fingers:1.4), (deformed, distorted, disfigured:1.3)", "scheduler": "EulerA", "steps": 20, "cfgScale": 7, "width": 512, "height": 512, "clipSkip": 2 } } ``` -------------------------------- ### GET /api/v1/model-versions/by-hash/:hash Source: https://developer.civitai.com/docs/api/public-rest Retrieves a model version using its file hash. ```APIDOC ## GET /api/v1/model-versions/by-hash/:hash ### Description Retrieves a model version using its file hash. ### Method GET ### Endpoint /api/v1/model-versions/by-hash/:hash ### Parameters #### Path Parameters - **hash** (string) - Required - The hash of the model file. ### Request Example *No specific request example provided in the source text for this endpoint.* ### Response *The response structure is expected to be similar to the GET /api/v1/model-versions/:id endpoint, but specific details for this endpoint were not provided.* ``` -------------------------------- ### Link Commands Source: https://developer.civitai.com/docs/link Defines the commands that can be sent to the Stable Diffusion instance once a link is established, including resource management and generation requests. ```APIDOC ## Base Command Structure ### Description All commands follow a base structure including a unique identifier, version, and timestamps. ### Method (Sent within the established room) ### Endpoint (N/A) ### Parameters #### Request Body - **id** (string) - Required - A unique identifier (UUID) for the request. - **version** (string) - Required - The semantic version of the request. - **createdAt** (Date) - Required - Timestamp when the request was created. - **updateAt** (Date) - Optional - Timestamp when the request was last updated. ### Request Example ```json { "id": "a1b2c3d4-e5f6-7890-1234-567890abcdef", "version": "1.0.0", "createdAt": "2023-10-27T10:00:00Z" } ``` --- ## `activities:list` (Alpha) ### Description Retrieves a list of the last 10 requests made through the link service. ### Method (Sent within the established room) ### Endpoint (N/A) ### Parameters #### Request Body - **id** (string) - Required - UUID for the request. - **version** (string) - Required - Semantic version. - **createdAt** (Date) - Required - Creation timestamp. ### Request Example ```json { "id": "uuid_activities_list", "version": "1.0.0", "createdAt": "2023-10-27T10:00:00Z" } ``` ### Response #### Success Response (200) - **id** (string) - UUID for the request. - **activities** (array) - An array containing details of the last 10 requests. - Each activity object contains details about a past request. #### Response Example ```json { "id": "uuid_activities_list", "activities": [ { /* ... details of last 10 requests ... */ }, { /* ... */ }, ... ] } ``` --- ## `resources:add` (Alpha) ### Description Adds new resources (like LoRAs or checkpoints) to the Stable Diffusion instance. It can specify download URLs if the resource is not locally present. ### Method (Sent within the established room) ### Endpoint (N/A) ### Parameters #### Request Body - **id** (string) - Required - UUID for the request. - **resources** (array) - Required - A list of resources to add. - **type** (string) - Required - Type of resource (e.g., 'lora', 'checkpoint'). - **hash** (string) - Required - SHA256 hash of the resource. - **name** (string) - Required - Name of the resource file. - **previewImage** (string) - Optional - URL to a preview image. - **url** (string) - Optional - URL to download the resource if it's missing locally. ### Request Example ```json { "id": "uuid_resources_add", "version": "1.0.0", "createdAt": "2023-10-27T10:00:00Z", "resources": [ { "type": "lora", "hash": "sha256_lora_hash", "name": "my_lora.safetensors", "previewImage": "http://example.com/lora_preview.png", "url": "http://example.com/lora.safetensors" } ] } ``` ### Response #### Success Response (200) - **id** (string) - UUID of the initial add request. - **resources** (array) - Status of the added resources. - **type**, **hash**, **name** (from request) - **status** (string) - Current status ('pending', 'processing', 'success', 'error', 'canceled'). - **progress** (number) - Progress of the operation (0-100.00). - **status** (string) - Overall status of the request. #### Response Example ```json { "id": "uuid_resources_add", "resources": [ { "type": "lora", "hash": "sha256_lora_hash", "name": "my_lora.safetensors", "status": "processing", "progress": 50.75 } ], "status": "processing" } ``` --- ## `resources:add:cancel` (Alpha) ### Description Cancels an ongoing `resources:add` request. ### Method (Sent within the established room) ### Endpoint (N/A) ### Parameters #### Request Body - **id** (string) - Required - The ID of the initial `resources:add` request to cancel. - **resources** (array) - Required - A list of resources to cancel. - **type** (string) - Required - Type of resource. - **hash** (string) - Required - SHA256 hash of the resource. ### Request Example ```json { "id": "uuid_resources_add_to_cancel", "version": "1.0.0", "createdAt": "2023-10-27T10:00:00Z", "resources": [ { "type": "lora", "hash": "sha256_lora_hash" } ] } ``` ### Response #### Success Response (200) - **id** (string) - UUID of the initial add request. - **resources** (array) - Status of the canceled resources. - **type**, **hash** (from request) - **status** (string) - Should be 'canceled'. - **status** (string) - Overall status of the cancellation request (e.g., 'success'). #### Response Example ```json { "id": "uuid_resources_add_to_cancel", "resources": [ { "type": "lora", "hash": "sha256_lora_hash", "status": "canceled" } ], "status": "success" } ``` --- ## `resources:remove` (Alpha) ### Description Removes resources from the Stable Diffusion instance. ### Method (Sent within the established room) ### Endpoint (N/A) ### Parameters #### Request Body - **id** (string) - Required - UUID for the request. - **resources** (array) - Required - A list of resources to remove. - **type** (string) - Required - Type of resource. - **hash** (string) - Required - SHA256 hash of the resource. ### Request Example ```json { "id": "uuid_resources_remove", "version": "1.0.0", "createdAt": "2023-10-27T10:00:00Z", "resources": [ { "type": "checkpoint", "hash": "sha256_checkpoint_hash" } ] } ``` ### Response #### Success Response (200) - **id** (string) - UUID of the remove request. - **resources** (array) - Status of the removed resources. - **type**, **hash** (from request) - **status** (string) - Current status ('pending', 'processing', 'success', 'error'). - **status** (string) - Overall status of the remove request. #### Response Example ```json { "id": "uuid_resources_remove", "resources": [ { "type": "checkpoint", "hash": "sha256_checkpoint_hash", "status": "pending" } ], "status": "pending" } ``` --- ## `resources:list` (Alpha) ### Description Lists available resources of specified types on the Stable Diffusion instance. ### Method (Sent within the established room) ### Endpoint (N/A) ### Parameters #### Request Body - **id** (string) - Required - UUID for the request. - **types** (array) - Required - An array of resource types to list (e.g., 'checkpoint', 'lora'). ### Request Example ```json { "id": "uuid_resources_list", "version": "1.0.0", "createdAt": "2023-10-27T10:00:00Z", "types": [ "lora", "checkpoint" ] } ``` ### Response #### Success Response (200) - **id** (string) - UUID of the list request. - **resources** (array) - A list of found resources. - **type** (string) - Type of resource. - **hash** (string) - SHA256 hash of the resource. - **name** (string) - Name of the resource file. - **path** (string) - Optional path to the resource file on the file system. #### Response Example ```json { "id": "uuid_resources_list", "resources": [ { "type": "lora", "hash": "sha256_lora_hash", "name": "my_lora.safetensors", "path": "/sd/models/lora/my_lora.safetensors" }, { "type": "checkpoint", "hash": "sha256_checkpoint_hash", "name": "base_model.safetensors" } ] } ``` ``` -------------------------------- ### Initialize Civitai Client (Node.js) Source: https://developer.civitai.com/docs/api/javascript-sdk Demonstrates how to create an instance of the Civitai client. Supports both ESM and CommonJS module formats. Requires an API token for authentication. ```javascript // ESM (where "type": module in package.json or using .mjs extension) import { Civitai } from "civitai"; // CommonJS (using .cjs extension) const Civitai = require("civitai"); ``` ```javascript const civitai = new Civitai({ auth: "YOUR_API_TOKEN", }); ``` -------------------------------- ### GET /api/v1/model-versions/by-hash/:hash Source: https://developer.civitai.com/docs/api/public-rest Retrieve a specific model version using its hash. ```APIDOC ## GET /api/v1/model-versions/by-hash/:hash ### Description Retrieves details for a specific model version identified by its hash. ### Method GET ### Endpoint `https://civitai.com/api/v1/model-versions/by-hash/:hash` ### Parameters #### Path Parameters - **hash** (string) - Required - The hash of the model version to retrieve. ``` -------------------------------- ### Run Tests with npm Source: https://developer.civitai.com/docs/api/javascript-sdk Executes the project's test suite to verify functionality. Ensure all dependencies are installed and an .env.test file with CIVITAI_API_TOKEN is present. ```bash npm run test ``` -------------------------------- ### GET /api/v1/creators Source: https://developer.civitai.com/docs/api/public-rest Retrieve a list of creators from the Civitai platform. You can filter and paginate the results. ```APIDOC ## GET /api/v1/creators ### Description Retrieves a list of creators on the Civitai platform. This endpoint supports filtering by username, pagination, and limiting the number of results. ### Method GET ### Endpoint `https://civitai.com/api/v1/creators` ### Query Parameters #### Path Parameters * None #### Query Parameters - **limit** (number) - Optional - The number of results to be returned per page. This can be a number between 0 and 200. By default, each page will return 20 results. If set to 0, it'll return all the creators. - **page** (number) - Optional - The page from which to start fetching creators. - **query** (string) - Optional - Search query to filter creators by username. ### Request Example ```bash curl https://civitai.com/api/v1/creators?limit=3 \ -H "Content-Type: application/json" \ -X GET ``` ### Response #### Success Response (200) - **items** (array) - An array of creator objects. - **username** (string) - The username of the creator. - **modelCount** (number) - The amount of models linked to this user. - **link** (string) - Url to get all models from this user. - **metadata** (object) - Pagination and total item information. - **totalItems** (string) - The total number of items available. - **currentPage** (string) - The current page you are at. - **pageSize** (string) - The size of the batch. - **totalPages** (string) - The total number of pages. - **nextPage** (string) - The url to get the next batch of items. - **prevPage** (string) - The url to get the previous batch of items. #### Response Example ```json { "items": [ { "username": "Civitai", "modelCount": 848, "link": "https://civitai.com/api/v1/models?username=Civitai" }, { "username": "JustMaier", "modelCount": 8, "link": "https://civitai.com/api/v1/models?username=JustMaier" }, { "username": "maxhulker", "modelCount": 2, "link": "https://civitai.com/api/v1/models?username=maxhulker" } ], "metadata": { "totalItems": 46, "currentPage": 1, "pageSize": 3, "totalPages": 16, "nextPage": "https://civitai.com/api/v1/creators?limit=3&page=2" } } ``` ``` -------------------------------- ### POST /intent/post Source: https://developer.civitai.com/docs/post-intent-system Initiates the process of creating a Civitai post by redirecting the user to a Civitai page with specified media and post details. An optional detailsUrl can be provided to fetch extra metadata about the media's creation. ```APIDOC ## POST /intent/post ### Description This endpoint initiates the Civitai post creation flow. It redirects the user to a Civitai page pre-populated with the provided media and post details. Optionally, a `detailsUrl` can be included to fetch additional metadata about the media's creation process, which will be displayed alongside the media on Civitai. ### Method GET ### Endpoint `https://civitai.com/intent/post` ### Query Parameters #### Query Parameters - **mediaUrl** (string) - Required - Absolute URL of the media to post. - **title** (string) - Optional - Title to use for the post. - **description** (string) - Optional - Text to use in the description of the post. - **tags** (string) - Optional - Comma-separated tags to apply to the post. Max of 5 tags. - **detailsUrl** (string) - Optional - URL to call to get additional parameters for the media (JSON). Only for approved domains. They can include parameters specific to your service so that people can have a better idea of how the media was made. ### Request Example ``` https://civitai.com/intent/post?mediaUrl=https://yoursite.com/image.jpg&title=New%20Post&description=my%20great%20image&tags=person,forest,green&detailsUrl=https://yoursite.com/api/image-details/123 ``` ### Response #### Success Response (200) This endpoint performs a redirect. The actual response will be a redirect to a Civitai page. #### Response Example (Redirect to Civitai post creation page with pre-filled data) ### Details URL Structure (for `detailsUrl` parameter) #### Request Body (for `detailsUrl` endpoint) - **source** (object) - Optional - Information about the service providing the media. - **name** (string) - Required - Name of your service. - **homepage** (string) - Optional - Your service's home URL. - **createUrl** (string) - Optional - Link back to the URL used to create the media. - **referenceUrl** (string) - Optional - URL to link back to the source of the media. - **details** (object) - Optional - Max 10 params. Key-value object for custom parameters specific to your service. - **details.[key]** (string | number | boolean) - Key-value pair for custom details. #### Details URL Response Example ```json { "source": { "name": "Your Service", "homepage": "https://yoursite.com" }, "createUrl": "https://yoursite.com/create/img?prompt=person%20in%20forest", "referenceUrl": "https://yoursite.com/images/[id]", "details": { "myParam": "special", "otherParam": 2, "anotherParam": true } } ``` ```