{"openapi":"3.0.3","info":{"description":"Pryon Generative API.","title":"Generative API Query Guardrails","version":"1.0"},"servers":[{"url":"{pryon_base_url}"}],"tags":[{"name":"Generative"}],"paths":{"/api/generative/v1alpha1/chat/completions":{"post":{"description":"A generic text-generation interface to external LLM providers and Pryon-hosted LLMs.\n implements a subset of the OpenAI /v1/chat/completions API specification\n as defined here: https://platform.openai.com/docs/api-reference/chat\n Using the official OpenAI client SDK for your language is recommended.\n The following providers are supported currently:\n - pryon\n - openai\n - anthropic\n - vertex ai\n Please check the respective provider's documentation\n for supported text-generation models and accepted sampling params.\n If streaming is enabled, responses will follow the SSE standard\n https://html.spec.whatwg.org/multipage/server-sent-events.html#server-sent-events.","operationId":"Generative_CreateChatCompletions","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ChatCompletionsRequest"}}},"required":true},"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ChatCompletionsResponse"}}},"description":"OK"},"default":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Status"}}},"description":"Default error response"}},"tags":["Generative"],"parameters":[{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"},"example":"Authorization: Bearer {base64-encoded-token}"},{"name":"x-pryon-org-id","in":"header","required":false,"schema":{"type":"string"},"description":"Organization ID; only required for organizations with multiple tenants.","example":"pryoninc.com"}]}},"/api/generative/v1alpha1/chat/completions/models":{"get":{"description":"Lists the models available for our Chat Completions API","operationId":"Generative_ListChatCompletionsModels","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ListChatCompletionsModelsRequest"}}},"required":true},"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ListChatCompletionsModelsResponse"}}},"description":"OK"},"default":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Status"}}},"description":"Default error response"}},"tags":["Generative"],"parameters":[{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"},"example":"Authorization: Bearer {base64-encoded-token}"},{"name":"x-pryon-org-id","in":"header","required":false,"schema":{"type":"string"},"description":"Organization ID; only required for organizations with multiple tenants.","example":"pryoninc.com"}]}},"/api/generative/v1alpha1/tasks/complete-query":{"post":{"description":"Generates a completed query by replacing references to entities / information\n in prior turns of the conversation.","operationId":"Generative_CompleteQuery","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CompleteQueryRequest"}}},"required":true},"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CompleteQueryResponse"}}},"description":"OK"},"default":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Status"}}},"description":"Default error response"}},"tags":["Generative"],"parameters":[{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"},"example":"Authorization: Bearer {base64-encoded-token}"},{"name":"x-pryon-org-id","in":"header","required":false,"schema":{"type":"string"},"description":"Organization ID; only required for organizations with multiple tenants.","example":"pryoninc.com"}]}},"/api/generative/v1alpha1/tasks/guardrail-query":{"post":{"summary":"Query Guardrails","description":"Return classifications for query toxicity and prompt injection.","operationId":"Generative_GuardrailQuery","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/QueryGuardrailsRequest"}}},"required":true},"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/QueryGuardrailsResponse"}}},"description":"OK"},"default":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Status"}}},"description":"Default error response"}},"tags":["Generative"],"parameters":[{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"},"example":"Authorization: Bearer {base64-encoded-token}"},{"name":"x-pryon-org-id","in":"header","required":false,"schema":{"type":"string"},"description":"Organization ID; only required for organizations with multiple tenants.","example":"pryoninc.com"}]}},"/api/generative/v1alpha1/tasks/route-query":{"post":{"description":"Return query out-of-domain classifications given a query","operationId":"Generative_RouteQuery","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/RouteQueryRequest"}}},"required":true},"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/RouteQueryResponse"}}},"description":"OK"},"default":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Status"}}},"description":"Default error response"}},"tags":["Generative"],"parameters":[{"name":"Authorization","in":"header","required":true,"schema":{"type":"string"},"example":"Authorization: Bearer {base64-encoded-token}"},{"name":"x-pryon-org-id","in":"header","required":false,"schema":{"type":"string"},"description":"Organization ID; only required for organizations with multiple tenants.","example":"pryoninc.com"}]}}},"components":{"schemas":{"ChatCompletionsModel":{"description":"An individual Chat Completions model","properties":{"id":{"description":"The id of the model. Either in the form of \"provider/model\" or \"provider/subprovider/model\"","type":"string"},"display_name":{"description":"The human friendly name of the model, used during selection in our UI","type":"string"}},"type":"object"},"ChatCompletionsModels":{"description":"A list of our Chat Completions models","properties":{"models":{"description":"List of all the available models for our Chat Completions API","items":{"$ref":"#/components/schemas/ChatCompletionsModel"},"type":"array"}},"type":"object"},"ChatCompletionsRequest":{"properties":{"messages":{"description":"List of messages that form the conversation","items":{"$ref":"#/components/schemas/Message"},"type":"array"},"model":{"description":"ID of the model to use, following the / format.\n e.g pryon/pryon-zeus-1, openai/gpt-4o, openai/o1-mini,\n anthropic/claude-3-5-sonnet-latest etc.","type":"string"},"temperature":{"description":"Sampling temperature.\n Range will depend on the specific model being called,\n Please check provider / model documentation.","format":"float","type":"number"},"top_p":{"description":"Alternative to temperature for nucleus sampling","format":"float","type":"number"},"stream":{"description":"Whether to stream partial message deltas","type":"boolean"},"stop":{"description":"Stop sequences where the API should stop generating","items":{"type":"string"},"type":"array"},"max_completion_tokens":{"description":"Maximum number of tokens to generate","format":"int32","type":"integer"},"logprobs":{"description":"Whether to return log probabilities of the output tokens or not.\n If true, returns the log probabilities of each output token returned in the content of message.","type":"boolean"},"top_logprobs":{"description":"An integer between 0 and 20 specifying the number of most likely tokens to return at each token position, each with an associated log probability.\n logprobs must be set to true if this parameter is used.","format":"int32","type":"integer"},"tools":{"description":"List of tools (functions) available to the model","items":{"$ref":"#/components/schemas/Tool"},"type":"array"},"tool_choice":{"allOf":[{"$ref":"#/components/schemas/GoogleProtobufValue"}],"description":"Specifies the tool called by the model when generating a response; the simple string options below dictate the LLM behavior; defaults to none if no tools are present.\n none: the model will not call any tool and instead generates a message.\n auto: the model picks between generating a message or calling one or more tools.\n required: the model must call one or more tools.\n To force the model to call a specific tool, see Calling Specific Tools."}},"type":"object"},"ChatCompletionsResponse":{"description":"Response for chat completion\n non-streaming: https://platform.openai.com/docs/api-reference/chat/object\n streaming: https://platform.openai.com/docs/api-reference/chat/streaming","properties":{"id":{"description":"Unique identifier for the chat completion","type":"string"},"choices":{"description":"A list of chat completion choices. Can be more than one if n is greater than 1.","items":{"$ref":"#/components/schemas/Choice"},"type":"array"},"created":{"description":"The Unix timestamp (in seconds) of when the chat completion was created.","type":"string"},"model":{"description":"Model used for completion","type":"string"},"object":{"description":"The object type, which can be either\n chat.completion OR\n chat.completion.chunk","type":"string"},"usage":{"allOf":[{"$ref":"#/components/schemas/Usage"}],"description":"Usage statistics for the completion"}},"type":"object"},"Choice":{"description":"Individual completion choice","properties":{"index":{"description":"Index of the choice","format":"int32","type":"integer"},"message":{"allOf":[{"$ref":"#/components/schemas/Message"}],"description":"The message containing the completion.\n Present only if stream=false in request."},"delta":{"allOf":[{"$ref":"#/components/schemas/Delta"}],"description":"The delta for a streaming chunk.\n Present only if stream=true in request."},"logprobs":{"description":"Log probability information for the choice.","items":{"$ref":"#/components/schemas/LogProbs"},"type":"array"},"finish_reason":{"description":"Reason why the completion finished","type":"string"}},"type":"object"},"CompleteQueryRequest":{"properties":{"query":{"description":"Query to complete given context.","type":"string"},"conversation_context":{"description":"Context for prior turns in the conversation.","type":"string"},"conversation_id":{"description":"Retrieve context history (question-answer pairs)\n from previous exchanges in the conversation.","type":"string"}},"type":"object"},"CompleteQueryResponse":{"properties":{"completed_query":{"type":"string"}},"type":"object"},"Delta":{"description":"Delta of a message for streaming","properties":{"role":{"description":"Role of the message sender (if changed)","type":"string"},"content":{"description":"Content delta of the message","type":"string"},"tool_calls":{"description":"For assistant messages: tool calls made by the model","items":{"$ref":"#/components/schemas/DeltaToolCall"},"type":"array"}},"type":"object"},"DeltaToolCall":{"description":"Tool call in assistant messages (for streamed responses)","properties":{"index":{"description":"Index of this tool call","format":"uint32","type":"integer"},"id":{"description":"Unique identifier for this tool call","type":"string"},"type":{"description":"Will be \"function\"","type":"string"},"function":{"allOf":[{"$ref":"#/components/schemas/FunctionCall"}],"description":"The function/tool to use"}},"type":"object"},"FunctionCall":{"description":"Function call details","properties":{"name":{"description":"Name of the function being called","type":"string"},"arguments":{"description":"JSON string of arguments","type":"string"}},"type":"object"},"FunctionDefinition":{"description":"Function definition matching OpenAI's FunctionDefinition","properties":{"name":{"description":"The name of the function to be called\n Must be a-z, A-Z, 0-9, or contain underscores and dashes, max 64 chars","type":"string"},"description":{"description":"Description of what the function does","type":"string"},"parameters":{"description":"JSON Schema as a string (since protobuf doesn't have native JSON Schema support)\n This corresponds to FunctionParameters: Dict[str, object]","type":"object"},"strict":{"description":"Whether to enable strict schema adherence","type":"boolean"}},"type":"object"},"GoogleProtobufAny":{"additionalProperties":true,"description":"Contains an arbitrary serialized message along with a @type that describes the type of the serialized message.","properties":{"@type":{"description":"The serialized message type.","type":"string"}},"type":"object"},"GoogleProtobufValue":{"description":"Represents a dynamically typed value which can be either null, a number, a string, a boolean, a recursive struct value, or a list of values."},"ListChatCompletionsModelsRequest":{"description":"The request schema for our ListChatCompletionsModels endpoint","properties":{},"type":"object"},"ListChatCompletionsModelsResponse":{"description":"Response for ListChatCompletionsModels\n Provides all the available models for our Chat Completions API","properties":{"items":{"additionalProperties":{"$ref":"#/components/schemas/ChatCompletionsModels"},"description":"List of all the available models for our Chat Completions API separated by provider","type":"object"}},"type":"object"},"LogProbToken":{"properties":{"token":{"description":"The token.","type":"string"},"logprob":{"description":"The log probability of this token, if it is within the top 20 most likely tokens.\n Otherwise, the value -9999.0 is used to signify that the token is very unlikely.","format":"float","type":"number"},"bytes":{"description":"A list of integers representing the UTF-8 bytes representation of the token.\n Useful in instances where characters are represented by multiple tokens\n and their byte representations must be combined to generate\n the correct text representation.\n Can be null if there is no bytes representation for the token.","items":{"format":"int32","type":"integer"},"type":"array"}},"type":"object"},"LogProbTokenWithTop":{"properties":{"token":{"description":"The token.","type":"string"},"logprob":{"description":"The log probability of this token, if it is within the top 20 most likely tokens.\n Otherwise, the value -9999.0 is used to signify that the token is very unlikely.","format":"float","type":"number"},"bytes":{"description":"A list of integers representing the UTF-8 bytes representation of the token.\n Useful in instances where characters are represented by multiple tokens\n and their byte representations must be combined to generate\n the correct text representation.\n Can be null if there is no bytes representation for the token.","items":{"format":"int32","type":"integer"},"type":"array"},"top_logprobs":{"description":"List of the most likely tokens and their log probability, at this token position.\n In rare cases, there may be fewer than the number of requested top_logprobs returned.","items":{"$ref":"#/components/schemas/LogProbToken"},"type":"array"}},"type":"object"},"LogProbs":{"properties":{"content":{"description":"A list of message content tokens with log probability information.","items":{"$ref":"#/components/schemas/LogProbTokenWithTop"},"type":"array"},"refusal":{"description":"A list of message refusal tokens with log probability information.","items":{"$ref":"#/components/schemas/LogProbTokenWithTop"},"type":"array"}},"type":"object"},"Message":{"description":"Individual message in the conversation","properties":{"role":{"description":"Role of the message sender (system, user, assistant)\n Please check provider documentation on what's supported\n for a particular model.","type":"string"},"content":{"description":"Content of the message","type":"string"},"tool_calls":{"description":"For assistant messages: tool calls made by the model","items":{"$ref":"#/components/schemas/ToolCall"},"type":"array"},"name":{"description":"Optional: A name for the participant. Provides the model information to differentiate between participants of the same role.","type":"string"}},"type":"object"},"QueryGuardrailsRequest":{"properties":{"query":{"description":"Query which is checked against the guardrail models.","type":"string"}},"type":"object"},"QueryGuardrailsResponse":{"properties":{"is_toxic":{"description":"Whether the given query contains toxic content.","type":"boolean"},"is_prompt_injection_attack":{"description":"Whether the given query contains a prompt injection attack.","type":"boolean"}},"type":"object"},"RouteQueryRequest":{"properties":{"query":{"description":"Query provided to generate a response.","type":"string"},"domain":{"description":"Brief definition of the subject domain of your collection.","type":"string"},"enable_generative_conversational_response":{"description":"Whether to generate a conversational response using the Pryon internal LLM; if false, no conversational response is returned.","type":"boolean"}},"type":"object"},"RouteQueryResponse":{"properties":{"is_intelligible":{"description":"Whether the given query is intelligible.","type":"boolean"},"is_english":{"description":"Whether he given query is in a supported language.","type":"boolean"},"is_conversational":{"description":"Whether the given query is conversational.","type":"boolean"},"conversational_response":{"description":"The LLM-generated response to a conversational query.","type":"string"}},"type":"object"},"Status":{"description":"The `Status` type defines a logical error model that is suitable for different programming environments, including REST APIs and RPC APIs. It is used by [gRPC](https://github.com/grpc). Each `Status` message contains three pieces of data: error code, error message, and error details. You can find out more about this error model and how to work with it in the [API Design Guide](https://cloud.google.com/apis/design/errors).","properties":{"code":{"description":"The status code; an enum value of the Google Remote Procedure Call (RPC).","format":"int32","type":"integer"},"message":{"description":"Developer-facing error message.","type":"string"},"details":{"description":"List of messages that carry the error details.","items":{"$ref":"#/components/schemas/GoogleProtobufAny"},"type":"array"}},"type":"object"},"Tool":{"description":"Tool definition for function calling","properties":{"type":{"description":"The type of tool - currently only \"function\" is supported","type":"string"},"function":{"allOf":[{"$ref":"#/components/schemas/FunctionDefinition"}],"description":"Function definition"}},"type":"object"},"ToolCall":{"description":"Tool call in assistant messages (for responses)","properties":{"id":{"description":"Unique identifier for this tool call","type":"string"},"type":{"description":"Will be \"function\"","type":"string"},"function":{"allOf":[{"$ref":"#/components/schemas/FunctionCall"}],"description":"The function/tool to use"}},"type":"object"},"Usage":{"description":"Usage statistics\n TODO: if we're going out to reasoning models,\n do we need to include those tokens separately?","properties":{"prompt_tokens":{"description":"Tokens in the prompt","format":"int32","type":"integer"},"completion_tokens":{"description":"Tokens in the completion","format":"int32","type":"integer"},"total_tokens":{"description":"Total tokens used","format":"int32","type":"integer"}},"type":"object"}}}}