OpenAI-compatible endpoint
Point an existing OpenAI client at a deployment by changing three values.
OpenAI-compatible endpoint A chat completion or text classification deployment also answers an OpenAI-compatible endpoint, so an existing OpenAI client works against it once you change three values. This page covers those values, streaming, the accepted parameters, and its errors. The three values - base url : https://api.dagnam.ai/v1 - api key : your deployment key - model : the deployment ID Example " \nclient.chat.completions.create \n model=" ",\n messages= "role": "user", "content": "Hello" ,\n ', , label: "curl", language: "bash", code: 'curl https://api.dagnam.ai/v1/chat/completions \\\n -H "Authorization: Bearer " \\\n -H "Content-Type: application/json" \\\n -d \' "model": " ", "messages": "role": "user", "content": "Hello" \'', , / GET /v1/models lists the one model your deployment key serves, so a client that calls client.models.list before chatting works too. Streaming Set "stream": true in the request body. The response is a series of server sent events shaped like an OpenAI chat.completion.chunk , ending with data: DONE . Accepted parameters Only model , messages , stream and n which must be 1 are accepted. user and metadata are accepted and ignored. Any other parameter, including max tokens and temperature , is rejected with an error rather than silently ignored. Errors Status Code When ------ ----------------------- --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 401 invalid api key The Authorization header is missing or malformed. On GET /v1/models , also a key that matches no deployment. 404 model not found The deployment ID is unknown, is not yours, or a request used the wrong key for it. Both cases answer identically, so a key cannot be used to probe for a deployment's existence. 503 model not ready The deployment is not currently running. 400 invalid request error The request body is malformed, for example messages is missing. 400 unsupported parameter n is not 1 , or the request includes a parameter this endpoint does not accept. 502 upstream error The model itself did not return a valid response. Errors use OpenAI's shape: "error": "message", "type", "param", "code" . This endpoint works for chat completion and text classification deployments.
Open in Dagnam.AI docs