
HTTP Request
Make an HTTP request to a public URL and get the status, headers and body back. JSON, form, text and multipart file uploads; internal addresses are refused.
api reference
about
make an http request to a public url and get the status, headers and body back. json, form, text and multipart file uploads; internal addresses are refused.
1. calling the api
install the client
the client provides a convenient way to interact with the api.
1pip install inferenceshsetup your api key
set INFERENCE_API_KEY as an environment variable. get your key from settings → api keys.
1export INFERENCE_API_KEY="inf_your_key"run and get result
submit a request and wait for the final result. best for batch processing or when you don't need progress updates.
1import os2from inferencesh import inference34client = inference(api_key=os.environ["INFERENCE_API_KEY"])567result = client.run({8 "app": "infsh/http",9 "input": {10 "url": "url"11 }12 })1314print(result["output"])stream live updates
get real-time progress updates as the task runs. ideal for showing progress bars, partial results, or long-running tasks.
1import os2from inferencesh import inference34client = inference(api_key=os.environ["INFERENCE_API_KEY"])567# stream=True yields updates as they arrive8for update in client.run({9 "app": "infsh/http",10 "input": {11 "url": "url"12 }13 }, stream=True):14 if update.get("progress"):15 print(f"progress: {update['progress']}%")16 if update.get("output"):17 print(f"output: {update['output']}")2. authentication
the api uses api keys for authentication. see the authentication docs for detailed setup instructions.
3. files
file inputs are automatically handled by the sdk. you can pass local paths, urls, or base64 data.
automatic upload
the python sdk automatically detects local file paths and uploads them. urls are passed through as-is.
1# local file paths are automatically uploaded2result = client.run({3 "app": "infsh/http",4 "input": {5 "image": "/path/to/local/image.png", # detected & uploaded6 "audio": "https://example.com/audio.mp3", # url passed through7 }8})4. webhooks
get notified when a task completes by providing a webhook url. when the task reaches a terminal state (completed, failed, or cancelled), a POST request is sent to your url with the task result.
1result = client.run({2 "app": "infsh/http",3 "input": {4 "url": "url"5 },6 "webhook": "https://your-server.com/webhook"7}, wait=False)webhook payload
your endpoint receives a JSON POST with the task result:
1{2 "event": "task.completed",3 "timestamp": "2024-01-15T10:30:05Z",4 "data": {5 "id": "task_abc123",6 "short_id": "abc123",7 "status": 10,8 "status_text": "completed",9 "output": { ... },10 "created_at": "2024-01-15T10:30:00Z",11 "updated_at": "2024-01-15T10:30:05Z"12 }13}5. schema
input
http method.
request url. http or https only; must resolve to a public internet address.
request headers. connection-level headers (host, content-length, connection, transfer-encoding, ...) are dropped.
query parameters, added to any already in the url. a list repeats the key.
json request body (any json value). sets content-type: application/json.
raw text request body. set content-type in headers (default text/plain; charset=utf-8).
form fields. sent application/x-www-form-urlencoded, or as multipart fields when files are given.
files to upload as multipart/form-data, optionally with form fields.
deadline for the whole request: connect, redirects and reading the body.
follow 3xx redirects. each hop is checked like the first.
most redirects to follow.
largest response body to read (decoded bytes).
when the body exceeds max_response_bytes: true returns the first max_response_bytes with truncated=true, false fails the task.
auto: json to body_json, small text to body_text, anything else to body_file. json/text/file force one.
output
body as a file, when binary, large, or response_as=file.
parsed body, when it is json.
body as text, when it is text.
time inside the app from sending the request to the end of the body.
url of the final response, after redirects.
response headers, lower-case names; repeated headers joined with ', '.
true when status is 2xx.
redirects followed.
body bytes read (after content decoding).
http status code of the final response.
true when the body was cut at max_response_bytes.
ready to run HTTP Request?
we use cookies
we use cookies to ensure you get the best experience on our website. for more information on how we use cookies, please see our cookie policy.
by clicking "accept", you agree to our use of cookies.
learn more.