Skip to main content
This guide will walk you through generating a Dependency Graph from a local repository.

Prerequisites

  1. API Key: You’ll need a Supermodel API key. Get one from the Dashboard.
  2. Codebase: A local folder containing the code you want to analyze.
  3. Tools: zip and curl installed on your machine.

Step 1: Prepare your code

The Supermodel API accepts code as a zipped archive. Navigate to your project folder and create a zip file, excluding hidden files like .git or node_modules to keep the upload size small.
# Zip your current directory, excluding hidden files and node_modules
zip -r repo.zip . -x ".*" -x "**/.*" -x "node_modules/*"

Step 2: Submit a graph generation job

Use the dependency endpoint to submit a graph generation job. Replace <your-api-key> with your actual key. The Idempotency-Key should be a unique value (like a UUID) for each request.
IDEMPOTENCY_KEY=$(uuidgen)

curl --request POST \
  --url https://api.supermodeltools.com/v1/graphs/dependency \
  --header "Idempotency-Key: $IDEMPOTENCY_KEY" \
  --header 'X-Api-Key: <your-api-key>' \
  --header 'Content-Type: multipart/form-data' \
  --form file='@repo.zip'
The API returns an HTTP 202 Accepted response with the job status:
{
  "status": "pending",
  "jobId": "550e8400-e29b-41d4-a716-446655440000",
  "retryAfter": 10
}
The $(uuidgen) command generates a unique ID automatically on macOS and Linux. On Windows, you can use [guid]::NewGuid() in PowerShell.

Step 3: Poll for results

Graph generation is asynchronous. Poll by re-submitting the same request with the same Idempotency-Key until the job completes:
# Re-submit the same request to check job status
curl --request POST \
  --url https://api.supermodeltools.com/v1/graphs/dependency \
  --header "Idempotency-Key: $IDEMPOTENCY_KEY" \
  --header 'X-Api-Key: <your-api-key>' \
  --header 'Content-Type: multipart/form-data' \
  --form file='@repo.zip'
When the job completes, you receive an HTTP 200 response with the graph inside the result field:
{
  "status": "completed",
  "jobId": "550e8400-e29b-41d4-a716-446655440000",
  "result": {
    "graph": {
      "nodes": [
        {
          "id": "src/main.ts",
          "labels": ["File"],
          "properties": { "name": "main.ts" }
        },
        {
          "id": "src/utils.ts",
          "labels": ["File"],
          "properties": { "name": "utils.ts" }
        }
      ],
      "relationships": [
        {
          "type": "imports",
          "startNode": "src/main.ts",
          "endNode": "src/utils.ts"
        }
      ]
    }
  }
}
Using the SDK? The @supermodeltools/sdk package handles polling automatically. See the Async Polling guide for details.

Next Steps

Explore other graph types to get different insights into your code: