import requests
url = "https://app.langwatch.ai/api/experiment/init"
payload = {
"experiment_slug": "<string>",
"experiment_id": "<string>"
}
headers = {
"X-Auth-Token": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'X-Auth-Token': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({experiment_slug: '<string>', experiment_id: '<string>'})
};
fetch('https://app.langwatch.ai/api/experiment/init', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));curl --request POST \
--url https://app.langwatch.ai/api/experiment/init \
--header 'Content-Type: application/json' \
--header 'X-Auth-Token: <api-key>' \
--data '
{
"experiment_slug": "<string>",
"experiment_id": "<string>"
}
'{
"slug": "<string>",
"path": "<string>"
}{
"message": "<string>"
}{
"message": "<string>"
}{
"error": "<string>",
"message": "<string>",
"fault": "<string>",
"tips": [
"<string>"
],
"docsUrl": "<string>",
"limitType": "<string>",
"current": 123,
"max": 123
}Create an experiment
Create an experiment, or return the existing one when the slug is already taken. This is the first call in an experiment run: take the slug back, report results against it, and every run under that slug groups together in the app. The SDKs call this endpoint for you.
import requests
url = "https://app.langwatch.ai/api/experiment/init"
payload = {
"experiment_slug": "<string>",
"experiment_id": "<string>"
}
headers = {
"X-Auth-Token": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'X-Auth-Token': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({experiment_slug: '<string>', experiment_id: '<string>'})
};
fetch('https://app.langwatch.ai/api/experiment/init', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));curl --request POST \
--url https://app.langwatch.ai/api/experiment/init \
--header 'Content-Type: application/json' \
--header 'X-Auth-Token: <api-key>' \
--data '
{
"experiment_slug": "<string>",
"experiment_id": "<string>"
}
'{
"slug": "<string>",
"path": "<string>"
}{
"message": "<string>"
}{
"message": "<string>"
}{
"error": "<string>",
"message": "<string>",
"fault": "<string>",
"tips": [
"<string>"
],
"docsUrl": "<string>",
"limitType": "<string>",
"current": 123,
"max": 123
}Authorizations
Project API key for sending traces and accessing project-scoped resources. Format: sk-lw-... (no underscore). Obtain one by creating a project via the Admin API or the LangWatch UI.
Body
- Option 1
- Option 2
Stable slug you choose. Reusing it returns the same experiment instead of creating another, which is what makes repeated runs land together.
BATCH_EVALUATION_V2 for SDK batch evaluations, DSPY for optimizer runs
DSPY, BATCH_EVALUATION, BATCH_EVALUATION_V2 Existing experiment id, as an alternative to the slug
Display name, used only when the experiment is created
Optimization Studio workflow this experiment belongs to
Was this page helpful?