Create a router
POST
/api/routers
CURL *hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "POST");curl_easy_setopt(hnd, CURLOPT_URL, "https://api.langparse.dev/api/routers");
struct curl_slist *headers = NULL;headers = curl_slist_append(headers, "X-Api-Key: <X-Api-Key>");headers = curl_slist_append(headers, "Content-Type: application/json");curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, "{ \"name\": \"Accounts Payable\", \"candidates\": [ { \"modelId\": \"mdl_inv01\", \"name\": \"Invoice\", \"keywords\": [ \"invoice\", \"tax\" ] } ] }");
CURLcode ret = curl_easy_perform(hnd);using System.Net.Http.Headers;var client = new HttpClient();var request = new HttpRequestMessage{ Method = HttpMethod.Post, RequestUri = new Uri("https://api.langparse.dev/api/routers"), Headers = { { "X-Api-Key", "<X-Api-Key>" }, }, Content = new StringContent("{ \"name\": \"Accounts Payable\", \"candidates\": [ { \"modelId\": \"mdl_inv01\", \"name\": \"Invoice\", \"keywords\": [ \"invoice\", \"tax\" ] } ] }") { Headers = { ContentType = new MediaTypeHeaderValue("application/json") } }};using (var response = await client.SendAsync(request)){ response.EnsureSuccessStatusCode(); var body = await response.Content.ReadAsStringAsync(); Console.WriteLine(body);}package main
import ( "fmt" "strings" "net/http" "io")
func main() {
url := "https://api.langparse.dev/api/routers"
payload := strings.NewReader("{ \"name\": \"Accounts Payable\", \"candidates\": [ { \"modelId\": \"mdl_inv01\", \"name\": \"Invoice\", \"keywords\": [ \"invoice\", \"tax\" ] } ] }")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-Api-Key", "<X-Api-Key>") 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))
}HttpRequest request = HttpRequest.newBuilder() .uri(URI.create("https://api.langparse.dev/api/routers")) .header("X-Api-Key", "<X-Api-Key>") .header("Content-Type", "application/json") .method("POST", HttpRequest.BodyPublishers.ofString("{ \"name\": \"Accounts Payable\", \"candidates\": [ { \"modelId\": \"mdl_inv01\", \"name\": \"Invoice\", \"keywords\": [ \"invoice\", \"tax\" ] } ] }")) .build();HttpResponse<String> response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());System.out.println(response.body());OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("application/json");RequestBody body = RequestBody.create(mediaType, "{ \"name\": \"Accounts Payable\", \"candidates\": [ { \"modelId\": \"mdl_inv01\", \"name\": \"Invoice\", \"keywords\": [ \"invoice\", \"tax\" ] } ] }");Request request = new Request.Builder() .url("https://api.langparse.dev/api/routers") .post(body) .addHeader("X-Api-Key", "<X-Api-Key>") .addHeader("Content-Type", "application/json") .build();
Response response = client.newCall(request).execute();import axios from 'axios';
const options = { method: 'POST', url: 'https://api.langparse.dev/api/routers', headers: {'X-Api-Key': '<X-Api-Key>', 'Content-Type': 'application/json'}, data: { name: 'Accounts Payable', candidates: [{modelId: 'mdl_inv01', name: 'Invoice', keywords: ['invoice', 'tax']}] }};
try { const { data } = await axios.request(options); console.log(data);} catch (error) { console.error(error);}const url = 'https://api.langparse.dev/api/routers';const options = { method: 'POST', headers: {'X-Api-Key': '<X-Api-Key>', 'Content-Type': 'application/json'}, body: '{"name":"Accounts Payable","candidates":[{"modelId":"mdl_inv01","name":"Invoice","keywords":["invoice","tax"]}]}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}val client = OkHttpClient()
val mediaType = MediaType.parse("application/json")val body = RequestBody.create(mediaType, "{ \"name\": \"Accounts Payable\", \"candidates\": [ { \"modelId\": \"mdl_inv01\", \"name\": \"Invoice\", \"keywords\": [ \"invoice\", \"tax\" ] } ] }")val request = Request.Builder() .url("https://api.langparse.dev/api/routers") .post(body) .addHeader("X-Api-Key", "<X-Api-Key>") .addHeader("Content-Type", "application/json") .build()
val response = client.newCall(request).execute()use serde_json::json;use reqwest;
#[tokio::main]pub async fn main() { let url = "https://api.langparse.dev/api/routers";
let payload = json!({ "name": "Accounts Payable", "candidates": ( json!({ "modelId": "mdl_inv01", "name": "Invoice", "keywords": ("invoice", "tax") }) ) });
let mut headers = reqwest::header::HeaderMap::new(); headers.insert("X-Api-Key", "<X-Api-Key>".parse().unwrap()); headers.insert("Content-Type", "application/json".parse().unwrap());
let client = reqwest::Client::new(); let response = client.post(url) .headers(headers) .json(&payload) .send() .await;
let results = response.unwrap() .json::<serde_json::Value>() .await .unwrap();
dbg!(results);}curl --request POST \ --url https://api.langparse.dev/api/routers \ --header 'Content-Type: application/json' \ --header 'X-Api-Key: <X-Api-Key>' \ --data '{ "name": "Accounts Payable", "candidates": [ { "modelId": "mdl_inv01", "name": "Invoice", "keywords": [ "invoice", "tax" ] } ] }'wget --quiet \ --method POST \ --header 'X-Api-Key: <X-Api-Key>' \ --header 'Content-Type: application/json' \ --body-data '{ "name": "Accounts Payable", "candidates": [ { "modelId": "mdl_inv01", "name": "Invoice", "keywords": [ "invoice", "tax" ] } ] }' \ --output-document \ - https://api.langparse.dev/api/routersCreate a router from a set of candidate models. Optionally pre-filter each candidate by keywords, set a confidence threshold + a defaultModelId fallback, and enable multi-document splitting via extractSubDocuments.
Authorizations
Section titled “Authorizations”Request Bodyrequired
Section titled “Request Bodyrequired”Media typeapplication/json
object
name
required
string
candidates
required
Candidate models (with optional keyword pre-filter).
Array<object>
object
modelId
string
name
string
keywords
Array<string>
defaultModelId
string
threshold
number
extractSubDocuments
string
Example
{ "name": "Accounts Payable", "candidates": [ { "modelId": "mdl_inv01", "name": "Invoice", "keywords": [ "invoice", "tax" ] } ]}Responses
Section titled “Responses”The created router.
Media typeapplication/json
object
data
required
A router. Own key id.
object
key
additional properties
any
Example
{ "data": { "id": "rtr_ap01", "name": "Accounts Payable", "enabled": true, "candidates": [ { "modelId": "mdl_inv01", "name": "Invoice", "keywords": [ "invoice", "tax" ] } ] }}Missing or invalid API key.
Media typeapplication/json
Error response. statusCode mirrors the HTTP status; statusMessage is human-readable.
object
statusCode
integer
statusMessage
string
Example
{ "statusCode": 404, "statusMessage": "Document not found"}