> This page is for version latest (default).
> For other versions, use one of these documentation indexes:
> - latest (default): https://docs.nvidia.com/alchemi/vasp/latest/llms.txt

> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.nvidia.com/alchemi/vasp/llms.txt.

# Run a calculation synchronously

POST http://localhost:8000/infer
Content-Type: application/json

Submit a calculation and block until it completes, then return the result. Use `/submit` instead to receive a request ID immediately without holding the connection open.


Reference: https://docs.nvidia.com/alchemi/vasp/alchemi-qc-api/calculations/infer

## Request

### Body (application/json)

This endpoint expects a VASPRequest.

- `config` (VASPConfig, required) — Configuration settings that define how to launch VASP.
- `atoms` (AtomicData, optional, nullable) — Atomic structure to evaluate. Supply either this field or a `POSCAR` entry in `files`, but not both.
- `info` (string, optional, nullable) — Optional metadata string echoed back on the reply.
- `files` (map from string to VaspRequestFiles, optional) — Input files to pass to the service. Keys are file names; values are either the file contents as plaintext or a reference to a previously uploaded file. An `INCAR` entry is required.

## Response

### 200

The calculation finished. The status code is 200 whether or not the calculation itself succeeded; inspect `success` and `failure_info` in the body.

- `atoms` (AtomicData, required) — The output atomic structure, which may differ from the input after a relaxation.
- `results` (VASPResult, required, nullable) — Results of the computation, or null if it failed.
- `config` (VASPConfig, required, nullable) — The configuration used for the calculation.
- `request_id` (string, optional, nullable) — Identifier used to correlate the reply with output files.
- `info` (string, optional, nullable) — The metadata string passed with the request.
- `success` (boolean, optional, default: true) — Whether the computation completed successfully.
- `failure_info` (FailureInformation, optional, nullable) — Failure details if the computation did not succeed.
- `memory` (MemoryStats, optional, nullable) — Memory usage statistics during the computation.
- `runtime` (double, optional, nullable) — Runtime of the computation in seconds, excluding queue time.

## Errors

### 422 Unprocessable Entity Error

The request failed validation.

- `detail` (string, required) — Human-readable description of the error.

### 500 Internal Server Error

The request could not be staged for execution.

- `detail` (string, required) — Human-readable description of the error.

## Types

### VASPConfig

Configuration that defines how VASP is launched for a calculation.

- `version` (enum, optional, default: std) — Which VASP executable to use: `std` for standard, `ncl` for non-collinear spins, `gam` for gamma-point only.
  - Allowed values: `std`, `ncl`, `gam`
- `potcar_type` (string, optional, default: PAW_PBE_64) — Which generation of POTCAR to use. Maps to a directory in the POTCAR library. Overridden when `potcar_defaults` is provided.
- `potcar_symbols` (list of string, optional, nullable) — Element symbols to use for the POTCAR file. The default POTCAR for an element shares its name, so only overrides need to be supplied (e.g. `Be_sv`).
- `potcar_defaults` (string, optional, nullable) — A preset list of pseudopotentials. Use `vasp-rec` for the recommended VASP set or the name of a pymatgen VaspInputSet. Cannot be combined with `potcar_symbols`.

### AtomicData

Software-agnostic description of an atomic structure.

- `coord` (list of double, required) — Atomic coordinates as a flat list [x1, y1, z1, x2, y2, z2, ...].
- `numbers` (list of integer, required) — Atomic numbers for each atom.
- `charge` (integer, optional, nullable, default: 0) — Total charge of the system.
- `mult` (integer, optional, nullable, default: 1) — Spin multiplicity (2S+1).
- `cell` (list of double, optional, nullable) — Unit cell as 9 elements in a flattened list.
- `pbc` (list of boolean, optional, default: [false,false,false]) — Periodic boundary condition flags for each cell vector.
- `structure_id` (string, optional, nullable, default: ) — Optional identifier for the structure.

### VaspRequestFiles

- string
- StagedInputFile: StagedInputFile

### VASPResult

Results parsed from a completed VASP calculation.

- `scf_converged` (boolean, required) — Whether the SCF calculation converged within tolerance.
- `opt_converged` (boolean, optional, nullable) — Whether the geometry optimization converged.
- `e_tot` (double, optional, nullable) — Total electronic energy in eV.
- `forces` (list of double, optional, nullable) — Nuclear gradients (forces) in eV/Angstrom, flattened.
- `stress` (list of double, optional, nullable) — Stress tensor components in kBar.
- `band_gap` (list of double, optional, nullable) — Band gap energy for the spin-up and spin-down bands in eV.
- `total_mag` (VaspResultTotalMag, optional, nullable) — Total magnetization as a scalar, or a vector for non-collinear calculations.
- `magmoms` (list of double, optional, nullable) — Magnetic moment for each atom. Length equals the number of atoms (collinear) or three times the number of atoms (non-collinear).
- `exit_code` (integer, optional, nullable) — The exit code from the VASP process.
- `stdout` (string, optional, nullable) — Standard output from VASP, truncated to 8192 characters.
- `stderr` (string, optional, nullable) — Standard error from VASP, truncated to 8192 characters.

### FailureInformation

Information about a task failure.

- `exception` (string, required) — The exception raised by the failed task.
- `traceback` (string, optional, nullable) — Full stack trace for the exception, if available.

### MemoryStats

Peak memory usage statistics collected during a calculation.

- `peak_gpu_mem` (double, optional, nullable) — Peak GPU memory usage in MB, or null if GPU monitoring was disabled.
- `peak_ram_mem` (double, optional, nullable) — Peak RAM usage in MB, or null if RAM monitoring was disabled.

### StagedInputFile

Reference to an input file uploaded via `/input/upload`.

- `file_id` (string, required) — ID of an input file provided via the `/input/upload` endpoint.

### VaspResultTotalMag

Total magnetization as a scalar, or a vector for non-collinear calculations.

- double
- list of double

## Examples

**Request**

```json
{
  "config": {
    "version": "std",
    "potcar_defaults": "vasp-rec"
  },
  "atoms": {
    "coord": [
      0,
      0,
      0
    ],
    "numbers": [
      29
    ],
    "cell": [
      3.52,
      0,
      0,
      0,
      3.52,
      0,
      0,
      0,
      3.52
    ],
    "pbc": [
      true,
      true,
      true
    ]
  },
  "files": {
    "INCAR": "ENCUT = 520"
  }
}
```

**Response**

```json
{
  "atoms": {
    "coord": [
      0,
      0,
      0,
      0.5,
      0.5,
      0
    ],
    "numbers": [
      29,
      29
    ],
    "charge": 0,
    "mult": 1,
    "cell": [
      3.52,
      0,
      0,
      0,
      3.52,
      0,
      0,
      0,
      3.52
    ],
    "pbc": [
      true
    ],
    "structure_id": ""
  },
  "results": {
    "scf_converged": true,
    "opt_converged": true,
    "e_tot": 1.1,
    "forces": [
      1.1
    ],
    "stress": [
      1.1
    ],
    "band_gap": [
      1.1
    ],
    "total_mag": 1.1,
    "magmoms": [
      1.1
    ],
    "exit_code": 1,
    "stdout": "string",
    "stderr": "string"
  },
  "config": {
    "version": "std",
    "potcar_type": "PAW_PBE_64",
    "potcar_symbols": [
      "Be_sv"
    ],
    "potcar_defaults": "vasp-rec"
  },
  "request_id": "string",
  "info": "string",
  "success": true,
  "failure_info": {
    "exception": "VASP Nonzero Exit",
    "traceback": "string"
  },
  "memory": {
    "peak_gpu_mem": 1.1,
    "peak_ram_mem": 1.1
  },
  "runtime": 1.1
}
```

**SDK Code**

```python Inline INCAR with atomic structure
import requests

url = "http://localhost:8000/infer"

payload = {
    "config": {
        "version": "std",
        "potcar_defaults": "vasp-rec"
    },
    "atoms": {
        "coord": [0, 0, 0],
        "numbers": [29],
        "cell": [3.52, 0, 0, 0, 3.52, 0, 0, 0, 3.52],
        "pbc": [True, True, True]
    },
    "files": { "INCAR": "ENCUT = 520" }
}
headers = {"Content-Type": "application/json"}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```javascript Inline INCAR with atomic structure
const url = 'http://localhost:8000/infer';
const options = {
  method: 'POST',
  headers: {'Content-Type': 'application/json'},
  body: '{"config":{"version":"std","potcar_defaults":"vasp-rec"},"atoms":{"coord":[0,0,0],"numbers":[29],"cell":[3.52,0,0,0,3.52,0,0,0,3.52],"pbc":[true,true,true]},"files":{"INCAR":"ENCUT = 520"}}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go Inline INCAR with atomic structure
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "http://localhost:8000/infer"

	payload := strings.NewReader("{\n  \"config\": {\n    \"version\": \"std\",\n    \"potcar_defaults\": \"vasp-rec\"\n  },\n  \"atoms\": {\n    \"coord\": [\n      0,\n      0,\n      0\n    ],\n    \"numbers\": [\n      29\n    ],\n    \"cell\": [\n      3.52,\n      0,\n      0,\n      0,\n      3.52,\n      0,\n      0,\n      0,\n      3.52\n    ],\n    \"pbc\": [\n      true,\n      true,\n      true\n    ]\n  },\n  \"files\": {\n    \"INCAR\": \"ENCUT = 520\"\n  }\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby Inline INCAR with atomic structure
require 'uri'
require 'net/http'

url = URI("http://localhost:8000/infer")

http = Net::HTTP.new(url.host, url.port)

request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n  \"config\": {\n    \"version\": \"std\",\n    \"potcar_defaults\": \"vasp-rec\"\n  },\n  \"atoms\": {\n    \"coord\": [\n      0,\n      0,\n      0\n    ],\n    \"numbers\": [\n      29\n    ],\n    \"cell\": [\n      3.52,\n      0,\n      0,\n      0,\n      3.52,\n      0,\n      0,\n      0,\n      3.52\n    ],\n    \"pbc\": [\n      true,\n      true,\n      true\n    ]\n  },\n  \"files\": {\n    \"INCAR\": \"ENCUT = 520\"\n  }\n}"

response = http.request(request)
puts response.read_body
```

```java Inline INCAR with atomic structure
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("http://localhost:8000/infer")
  .header("Content-Type", "application/json")
  .body("{\n  \"config\": {\n    \"version\": \"std\",\n    \"potcar_defaults\": \"vasp-rec\"\n  },\n  \"atoms\": {\n    \"coord\": [\n      0,\n      0,\n      0\n    ],\n    \"numbers\": [\n      29\n    ],\n    \"cell\": [\n      3.52,\n      0,\n      0,\n      0,\n      3.52,\n      0,\n      0,\n      0,\n      3.52\n    ],\n    \"pbc\": [\n      true,\n      true,\n      true\n    ]\n  },\n  \"files\": {\n    \"INCAR\": \"ENCUT = 520\"\n  }\n}")
  .asString();
```

```php Inline INCAR with atomic structure
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'http://localhost:8000/infer', [
  'body' => '{
  "config": {
    "version": "std",
    "potcar_defaults": "vasp-rec"
  },
  "atoms": {
    "coord": [
      0,
      0,
      0
    ],
    "numbers": [
      29
    ],
    "cell": [
      3.52,
      0,
      0,
      0,
      3.52,
      0,
      0,
      0,
      3.52
    ],
    "pbc": [
      true,
      true,
      true
    ]
  },
  "files": {
    "INCAR": "ENCUT = 520"
  }
}',
  'headers' => [
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

```csharp Inline INCAR with atomic structure
using RestSharp;

var client = new RestClient("http://localhost:8000/infer");
var request = new RestRequest(Method.POST);
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"config\": {\n    \"version\": \"std\",\n    \"potcar_defaults\": \"vasp-rec\"\n  },\n  \"atoms\": {\n    \"coord\": [\n      0,\n      0,\n      0\n    ],\n    \"numbers\": [\n      29\n    ],\n    \"cell\": [\n      3.52,\n      0,\n      0,\n      0,\n      3.52,\n      0,\n      0,\n      0,\n      3.52\n    ],\n    \"pbc\": [\n      true,\n      true,\n      true\n    ]\n  },\n  \"files\": {\n    \"INCAR\": \"ENCUT = 520\"\n  }\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Inline INCAR with atomic structure
import Foundation

let headers = ["Content-Type": "application/json"]
let parameters = [
  "config": [
    "version": "std",
    "potcar_defaults": "vasp-rec"
  ],
  "atoms": [
    "coord": [0, 0, 0],
    "numbers": [29],
    "cell": [3.52, 0, 0, 0, 3.52, 0, 0, 0, 3.52],
    "pbc": [true, true, true]
  ],
  "files": ["INCAR": "ENCUT = 520"]
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "http://localhost:8000/infer")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```