Skip to content

638Labs AI Gateway

API example

curl -N https://sto0.638labs.com/api/v1 \
-H "Content-Type: application/json" \
-H "Authorization: Bearer process.env.YOUR_638LABS_API_KEY" \
-H "X-Provider-Authorization: Bearer process.env.ENDPOINT_PROVIDER_API_KEY" \
-d '{
"route": "openai/gpt-4o",
"payload": {
"model": "gpt-4o",
"messages": [
{
"role": "user",
"content": "Write a one-sentence bedtime story about a unicorn."
}
],
"stream" : false
}
}'

OpenAI compatible Note: This means, if you need to set any headers starting with “OpenAI”, they will be passed thru to the target endpoint.

For example:

-H "OpenAI-Organization: YOUR_ORG_ID" \
-H "OpenAI-Project: $PROJECT_ID"

Therefore a full example would be:

curl -N https://sto0.638labs.com/api/v1 \
-H "Content-Type: application/json" \
-H "Authorization: Bearer process.env.YOUR_638LABS_API_KEY" \
-H "X-Provider-Authorization: Bearer process.env.ENDPOINT_PROVIDER_API_KEY" \
-H "OpenAI-Organization: YOUR_ORG_ID" \
-H "OpenAI-Project: $PROJECT_ID"
-d '{
"route": "openai/gpt-4o",
"payload": {
"model": "gpt-4o",
"messages": [
{
"role": "user",
"content": "Write a one-sentence bedtime story about a unicorn."
}
],
"stream" : false
}
}'

Further reading