{"openapi":"3.1.0","info":{"title":"Detoxify API","version":"1.0.0","description":"Send text, get back scores for toxicity, insults, threats and more. Free to start, no setup."},"servers":[{"url":"https://api.staging.detoxify.sh"}],"tags":[{"name":"Analysis"}],"paths":{"/v1/analyze":{"post":{"operationId":"analyze","responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AnalyzeResponse"}}},"description":"Success."},"400":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}},"description":"`invalid_request`: The request body or parameters are not valid."},"401":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}},"description":"`unauthorized`: The API key or token sent with the request is not valid."},"402":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}},"description":"`account_suspended`: The account is suspended until its unpaid usage is paid. See `help_url` to pay it."},"413":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}},"description":"`payload_too_large`: The request body is too large."},"429":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}},"description":"`quota_exceeded`: The free plan's monthly allowance is used up. See `help_url` to subscribe for more.\n\n`anonymous_quota_exceeded`: Requests without an API key are limited per day. See `help_url` to sign up for more.\n\n`rate_limited`: Too many requests in a short time. Wait for `Retry-After` seconds and retry."},"500":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}},"description":"`internal_error`: An unexpected error occurred."},"502":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}},"description":"`analysis_failed`: The analysis engine failed on this request. Retrying may succeed."},"503":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}},"description":"`auth_unavailable`: The credential could not be checked right now. It may be valid; retry without discarding it.\n\n`metering_unavailable`: Usage could not be recorded right now, so the request was not served. Retry.\n\n`overloaded`: The service is at capacity or still starting. Retry shortly."},"504":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}},"description":"`analysis_timeout`: The analysis did not complete in time. Retrying may succeed."}},"security":[{"bearerAuth":[]}],"summary":"Analyze text","tags":["Analysis"],"description":"Scores one piece of text for toxicity and related categories. Send `{\"text\": ...}` as `application/json`, or send the text itself as the body: a body with any other content type, or none, is read as plain UTF-8 text.\n\nAlso served at `/analyze`, which behaves the same.","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AnalyzeRequest"}},"text/plain":{"schema":{"type":"string","maxLength":10000,"description":"The text to analyze."}}},"required":true}},"get":{"operationId":"analyzeQuery","responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AnalyzeResponse"}}},"description":"Success."},"400":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}},"description":"`invalid_request`: The request body or parameters are not valid."},"401":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}},"description":"`unauthorized`: The API key or token sent with the request is not valid."},"402":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}},"description":"`account_suspended`: The account is suspended until its unpaid usage is paid. See `help_url` to pay it."},"429":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}},"description":"`quota_exceeded`: The free plan's monthly allowance is used up. See `help_url` to subscribe for more.\n\n`anonymous_quota_exceeded`: Requests without an API key are limited per day. See `help_url` to sign up for more.\n\n`rate_limited`: Too many requests in a short time. Wait for `Retry-After` seconds and retry."},"500":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}},"description":"`internal_error`: An unexpected error occurred."},"502":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}},"description":"`analysis_failed`: The analysis engine failed on this request. Retrying may succeed."},"503":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}},"description":"`auth_unavailable`: The credential could not be checked right now. It may be valid; retry without discarding it.\n\n`metering_unavailable`: Usage could not be recorded right now, so the request was not served. Retry.\n\n`overloaded`: The service is at capacity or still starting. Retry shortly."},"504":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}},"description":"`analysis_timeout`: The analysis did not complete in time. Retrying may succeed."}},"security":[{"bearerAuth":[]}],"summary":"Analyze text in the URL","tags":["Analysis"],"description":"The same analysis, with the text in the query string: `GET /v1/analyze?text=...`. Handy from a browser or a one-line script. Addresses are limited in length (about 16 KB at our edge, after URL encoding), and proxies and browsers may record them, so send long or private text with POST instead.\n\nAlso served at `/analyze`, which behaves the same.","parameters":[{"description":"The text to analyze.","in":"query","name":"text","required":true,"schema":{"type":"string","maxLength":10000,"description":"The text to analyze."}}]}}},"components":{"schemas":{"ErrorResponse":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string","enum":["invalid_request","unauthorized","signup_not_allowed","not_found","payload_too_large","quota_exceeded","account_suspended","anonymous_quota_exceeded","rate_limited","internal_error","analysis_failed","overloaded","auth_unavailable","metering_unavailable","analysis_timeout"],"description":"Stable, machine-readable error code."},"message":{"type":"string","description":"Human-readable explanation. Not stable; do not parse."},"details":{"description":"Per-field problems, present on `invalid_request`.","type":"array","items":{"type":"object","properties":{"path":{"type":"string"},"message":{"type":"string"}},"required":["path","message"],"additionalProperties":false}},"help_url":{"description":"Where to resolve the problem, present on quota and suspension errors.","type":"string"}},"required":["code","message"],"additionalProperties":false}},"required":["error"],"additionalProperties":false},"AnalyzeResponse":{"type":"object","properties":{"model":{"type":"string","enum":["original"],"description":"The model that produced the scores."},"scores":{"$ref":"#/components/schemas/Scores"}},"required":["model","scores"],"additionalProperties":false},"Scores":{"type":"object","properties":{"toxicity":{"type":"number","minimum":0,"maximum":1,"description":"Probability from 0 to 1 that the text is toxic."},"severe_toxicity":{"type":"number","minimum":0,"maximum":1,"description":"Probability from 0 to 1 that the text is severely toxic."},"obscene":{"type":"number","minimum":0,"maximum":1,"description":"Probability from 0 to 1 that the text is obscene."},"threat":{"type":"number","minimum":0,"maximum":1,"description":"Probability from 0 to 1 that the text is a threat."},"insult":{"type":"number","minimum":0,"maximum":1,"description":"Probability from 0 to 1 that the text is an insult."},"identity_attack":{"type":"number","minimum":0,"maximum":1,"description":"Probability from 0 to 1 that the text is an attack on identity."}},"required":["toxicity","severe_toxicity","obscene","threat","insult","identity_attack"],"additionalProperties":false},"AnalyzeRequest":{"type":"object","properties":{"text":{"type":"string","maxLength":10000,"description":"The text to analyze."}},"required":["text"],"additionalProperties":false}},"securitySchemes":{"bearerAuth":{"description":"Your API key: `Authorization: Bearer dtx_...`. Requests with no key are served up to a small daily limit.","scheme":"bearer","type":"http"}}}}