API Responses
Learn about response codes on Beam.
Response codes
Beam uses standard HTTP codes to indicate the success or failure of your requests.
In general, 2xx
HTTP codes correspond to success, 4xx
codes are for user-related failures, and 5xx
codes are for infrastructure issues.
Status | Description |
---|---|
200 | Successful request. |
400 | Check that the parameters were correct. |
401 | The auth token used was invalid. |
5xx | Indicates an API timeout or an error with Beam servers. |
Returning Custom Status Codes with FastAPI
You might want to return special status codes from your REST API. Beam supports FastAPI responses, so you can return custom status codes.
For example, you could return a 404
status code with a custom message in your handler
function:
run.py
from fastapi import FastAPI
from fastapi.responses import JSONResponse
def custom_api_response():
return JSONResponse(
status_code=404,
content={"message": "You need more tokens"}
)
Was this page helpful?