FriendliAI Serverless.Responses API
The Serverless.Responses API from FriendliAI — 2 operation(s) for serverless.responses.
The Serverless.Responses API from FriendliAI — 2 operation(s) for serverless.responses.
openapi: 3.1.0
info:
title: Friendli Suite API Reference Container.Audio Serverless.Responses API
description: This is an OpenAPI reference of Friendli Suite API.
termsOfService: https://friendli.ai/terms-of-service
contact:
name: FriendliAI Support Team
email: support@friendli.ai
version: 0.1.0
servers:
- url: https://api.friendli.ai
tags:
- name: Serverless.Responses
paths:
/serverless/v1/responses:
post:
tags:
- Serverless.Responses
summary: Responses
description: Generate a model response from text or image inputs. Follows the OpenAI Responses API format, with support for streaming, function and custom tool calls, structured outputs, and reasoning controls.
operationId: serverlessResponses
security:
- token: []
parameters:
- name: X-Friendli-Team
in: header
required: false
schema:
anyOf:
- type: string
- type: 'null'
description: ID of team to run requests as (optional parameter).
title: X-Friendli-Team
description: ID of team to run requests as (optional parameter).
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/ServerlessResponsesBody'
responses:
'200':
description: Successfully generated a response.
content:
application/json:
schema:
$ref: '#/components/schemas/ServerlessResponsesSuccess'
examples:
Example:
value:
id: resp_4b71d12c86d94e719c7e3984a7bb7941
object: response
created_at: 1735722153
status: completed
output:
- type: message
id: msg_4b71d12c86d94e719c7e3984a7bb7941
status: completed
role: assistant
content:
- type: output_text
text: Hello there, how may I assist you today?
usage:
input_tokens: 9
input_tokens_details:
cached_tokens: 0
output_tokens: 11
output_tokens_details:
reasoning_tokens: 0
total_tokens: 20
model: zai-org/GLM-5.2
'422':
description: Unprocessable Entity
x-speakeasy-name-override: responses
x-mint:
metadata:
title: Model APIs Responses
sidebarTitle: Responses
og:title: Model APIs Responses
description: Generate a model response from text or image inputs. Follows the OpenAI Responses API format, with support for streaming, function and custom tool calls, structured outputs, and reasoning controls.
og:description: Generate a model response from text or image inputs. Follows the OpenAI Responses API format, with support for streaming, function and custom tool calls, structured outputs, and reasoning controls.
tag: Beta
href: /openapi/model-apis/responses
content: 'Generate a model response from text or image inputs. Follows the OpenAI Responses API format, with support for streaming, function and custom tool calls, structured outputs, and reasoning controls.
See available models at [this pricing table](/guides/model-apis/pricing#billing-methods).
<Note>
The Responses API may not be supported by all models available on Model APIs.
</Note>
To request successfully, it is mandatory to enter a **Personal API Key** (e.g. flp_XXX) value in the **Bearer Token** field.
Refer to the [authentication section](/openapi/introduction#authentication) on our introduction page to learn how to acquire this variable and [visit here](https://friendli.ai/suite/~/setting/keys) to generate your API Key.
When streaming mode is used (i.e., `stream` option is set to `true`), the response is in MIME type `text/event-stream`. Otherwise, the content type is `application/json`.
You can view the schema of the streamed sequence of chunk objects in streaming mode [here](/openapi/model-apis/responses-chunk-object).
<Info>
This API is currently in **Beta**.
While we strive to provide a stable and reliable experience, this feature is still under active development.
As a result, you may encounter unexpected behavior or limitations.
We encourage you to provide feedback to help us improve the feature before its official release.
- [Feature request & feedback](mailto:support@friendli.ai)
- [Contact support](mailto:support@friendli.ai)
</Info>'
/serverless/v1/responses#stream:
post:
tags:
- Serverless.Responses
summary: Stream responses
description: Generate a model response from text or image inputs. Follows the OpenAI Responses API format, with support for streaming, function and custom tool calls, structured outputs, and reasoning controls.
operationId: serverlessResponsesStream
security:
- token: []
parameters:
- name: X-Friendli-Team
in: header
required: false
schema:
anyOf:
- type: string
- type: 'null'
description: ID of team to run requests as (optional parameter).
title: X-Friendli-Team
description: ID of team to run requests as (optional parameter).
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/ServerlessResponsesStreamBody'
responses:
'200':
description: Successfully generated a streamed response.
content:
text/event-stream:
examples:
Example:
value: 'event: response.created
data: {"type":"response.created","response":{"id":"resp_4b71d12c86d94e719c7e3984a7bb7941","object":"response","created_at":1735722153,"status":"in_progress","output":[]},"sequence_number":0}
event: response.output_item.added
data: {"type":"response.output_item.added","output_index":0,"item":{"type":"message","id":"msg_4b71d12c86d94e719c7e3984a7bb7941","status":"in_progress","role":"assistant","content":[]},"sequence_number":1}
event: response.content_part.added
data: {"type":"response.content_part.added","item_id":"msg_4b71d12c86d94e719c7e3984a7bb7941","output_index":0,"content_index":0,"part":{"type":"output_text","text":""},"sequence_number":2}
event: response.output_text.delta
data: {"type":"response.output_text.delta","item_id":"msg_4b71d12c86d94e719c7e3984a7bb7941","output_index":0,"content_index":0,"delta":"Hello","sequence_number":3}
...
event: response.output_text.done
data: {"type":"response.output_text.done","item_id":"msg_4b71d12c86d94e719c7e3984a7bb7941","output_index":0,"content_index":0,"text":"Hello there, how may I assist you today?","sequence_number":8}
event: response.content_part.done
data: {"type":"response.content_part.done","item_id":"msg_4b71d12c86d94e719c7e3984a7bb7941","output_index":0,"content_index":0,"part":{"type":"output_text","text":"Hello there, how may I assist you today?"},"sequence_number":9}
event: response.output_item.done
data: {"type":"response.output_item.done","output_index":0,"item":{"type":"message","id":"msg_4b71d12c86d94e719c7e3984a7bb7941","status":"completed","role":"assistant","content":[{"type":"output_text","text":"Hello there, how may I assist you today?"}]},"sequence_number":10}
event: response.completed
data: {"type":"response.completed","response":{"id":"resp_4b71d12c86d94e719c7e3984a7bb7941","object":"response","created_at":1735722153,"status":"completed","output":[{"type":"message","id":"msg_4b71d12c86d94e719c7e3984a7bb7941","status":"completed","role":"assistant","content":[{"type":"output_text","text":"Hello there, how may I assist you today?"}]}],"usage":{"input_tokens":9,"input_tokens_details":{"cached_tokens":0},"output_tokens":11,"output_tokens_details":{"reasoning_tokens":0},"total_tokens":20},"model":"zai-org/GLM-5.2"},"sequence_number":11}
'
schema:
$ref: '#/components/schemas/ServerlessResponsesStreamSuccess'
'422':
description: Unprocessable Entity
x-speakeasy-name-override: stream
x-mint:
metadata:
title: Model APIs Stream Responses
sidebarTitle: Stream Responses
og:title: Model APIs Stream Responses
description: Generate a model response from text or image inputs. Follows the OpenAI Responses API format, with support for streaming, function and custom tool calls, structured outputs, and reasoning controls.
og:description: Generate a model response from text or image inputs. Follows the OpenAI Responses API format, with support for streaming, function and custom tool calls, structured outputs, and reasoning controls.
tag: Beta
content: 'Generate a model response from text or image inputs. Follows the OpenAI Responses API format, with support for streaming, function and custom tool calls, structured outputs, and reasoning controls.
See available models at [this pricing table](/guides/model-apis/pricing#billing-methods).
<Note>
The Responses API may not be supported by all models available on Model APIs.
</Note>
To request successfully, it is mandatory to enter a **Personal API Key** (e.g. flp_XXX) value in the **Bearer Token** field.
Refer to the [authentication section](/openapi/introduction#authentication) on our introduction page to learn how to acquire this variable and [visit here](https://friendli.ai/suite/~/setting/keys) to generate your API Key.
When streaming mode is used (i.e., `stream` option is set to `true`), the response is in MIME type `text/event-stream`. Otherwise, the content type is `application/json`.
You can view the schema of the streamed sequence of chunk objects in streaming mode [here](/openapi/model-apis/responses-chunk-object).
<Info>
This API is currently in **Beta**.
While we strive to provide a stable and reliable experience, this feature is still under active development.
As a result, you may encounter unexpected behavior or limitations.
We encourage you to provide feedback to help us improve the feature before its official release.
- [Feature request & feedback](mailto:support@friendli.ai)
- [Contact support](mailto:support@friendli.ai)
</Info>'
components:
schemas:
ResponsesInputTokensDetails:
properties:
cached_tokens:
type: integer
title: Cached Tokens
description: The number of tokens that were retrieved from the cache.
type: object
required:
- cached_tokens
title: ResponsesInputTokensDetails
ResponsesFunctionCallOutput:
properties:
type:
type: string
const: function_call_output
title: Type
description: The type of the function tool call output. Always `function_call_output`.
call_id:
type: string
title: Call Id
description: The unique ID of the function tool call generated by the model.
output:
anyOf:
- type: string
- items:
$ref: '#/components/schemas/ResponsesFunctionCallOutputContent'
type: array
title: Output
description: Text or image output of the function tool call. Can be a JSON string of the output, or an array of content parts (text or image).
id:
anyOf:
- type: string
- type: 'null'
title: Id
description: The unique ID of the function tool call output.
status:
anyOf:
- type: string
enum:
- in_progress
- completed
- incomplete
- type: 'null'
title: Status
description: The status of the item. One of `in_progress`, `completed`, or `incomplete`.
type: object
required:
- type
- call_id
- output
title: ResponsesFunctionCallOutput
ResponsesTextFormatJsonSchema:
properties:
type:
type: string
const: json_schema
title: Type
description: The type of response format being defined. Always `json_schema`.
name:
type: string
title: Name
description: The name of the response format. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64.
schema:
additionalProperties: true
type: object
title: Schema
description: The schema for the response format, described as a JSON Schema object.
description:
anyOf:
- type: string
- type: 'null'
title: Description
description: A description of what the response format is for, used by the model to determine how to respond in the format.
strict:
anyOf:
- type: boolean
- type: 'null'
title: Strict
description: Whether to enable strict schema adherence when generating the output. If set to true, the model will always follow the exact schema defined in the `schema` field. Only a subset of JSON Schema is supported when `strict` is `true`.
type: object
required:
- type
- name
- schema
title: ResponsesTextFormatJsonSchema
ResponsesStreamReasoningTextDone:
properties:
type:
type: string
const: response.reasoning_text.done
title: Type
description: The type of the event.
item_id:
type: string
title: Item Id
description: The ID of the reasoning output item.
output_index:
type: integer
title: Output Index
description: The index of the output item.
content_index:
type: integer
title: Content Index
description: The index of the reasoning content part.
text:
type: string
title: Text
description: The full text of the completed reasoning content.
sequence_number:
type: integer
title: Sequence Number
description: The sequence number for this event.
type: object
required:
- type
- item_id
- output_index
- content_index
- text
- sequence_number
title: ResponsesStreamReasoningTextDone
ResponsesFunctionTool:
properties:
type:
type: string
const: function
title: Type
description: The type of the function tool. Always `function`.
name:
type: string
title: Name
description: The name of the function to call.
parameters:
additionalProperties: true
type: object
title: Parameters
description: A JSON schema object describing the parameters of the function.
strict:
anyOf:
- type: boolean
- type: 'null'
title: Strict
description: Whether to enforce strict parameter validation. Default `true`.
description:
anyOf:
- type: string
- type: 'null'
title: Description
description: A description of the function. Used by the model to determine whether or not to call the function.
type: object
required:
- type
- name
- parameters
title: ResponsesFunctionTool
ResponsesInputText:
properties:
type:
type: string
const: input_text
title: Type
description: The type of the input item. Always `input_text`.
text:
type: string
title: Text
description: The text input to the model.
type: object
required:
- type
- text
title: ResponsesInputText
ResponsesStreamResponseEvent:
properties:
type:
type: string
enum:
- response.created
- response.in_progress
- response.completed
- response.incomplete
- response.failed
title: Type
description: The type of the event.
response:
$ref: '#/components/schemas/ResponsesSuccess'
description: The response snapshot associated with this lifecycle event.
sequence_number:
type: integer
title: Sequence Number
description: The sequence number for this event.
type: object
required:
- type
- response
- sequence_number
title: ResponsesStreamResponseEvent
ServerlessResponsesBody:
properties:
input:
anyOf:
- type: string
- items:
$ref: '#/components/schemas/ResponsesInputItem'
type: array
title: Input
description: Text or image inputs to the model, used to generate a response.
instructions:
anyOf:
- type: string
- type: 'null'
title: Instructions
description: A system (or developer) message inserted into the model's context.
max_output_tokens:
anyOf:
- type: integer
- type: 'null'
title: Max Output Tokens
description: An upper bound for the number of tokens that can be generated for a response, including visible output tokens and reasoning tokens.
temperature:
anyOf:
- type: number
- type: 'null'
title: Temperature
description: What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. We generally recommend altering this or `top_p` but not both.
top_p:
anyOf:
- type: number
- type: 'null'
title: Top P
description: An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with `top_p` probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered. We generally recommend altering this or `temperature` but not both.
parallel_tool_calls:
anyOf:
- type: boolean
- type: 'null'
title: Parallel Tool Calls
description: Whether to allow the model to run tool calls in parallel.
tools:
anyOf:
- items:
$ref: '#/components/schemas/ResponsesTool'
type: array
- type: 'null'
title: Tools
description: An array of tools the model may call while generating a response. You can specify which tool to use by setting the `tool_choice` parameter.
tool_choice:
anyOf:
- anyOf:
- type: string
enum:
- none
- auto
- required
- $ref: '#/components/schemas/ResponsesToolChoiceFunction'
- $ref: '#/components/schemas/ResponsesToolChoiceCustom'
description: Controls which (if any) tool is called by the model. `none` means the model will not call any tool and instead generates a message. `auto` means the model can pick between generating a message or calling one or more tools. `required` means the model must call one or more tools. An object can be used to force the model to call a specific function or custom tool.
- type: 'null'
title: Tool Choice
description: How the model should select which tool (or tools) to use when generating a response. See the `tools` parameter to see how to specify which tools the model can call.
text:
anyOf:
- $ref: '#/components/schemas/ResponsesTextConfig'
- type: 'null'
description: Configuration options for a text response from the model. Can be plain text or structured JSON data.
reasoning:
anyOf:
- $ref: '#/components/schemas/ResponsesReasoningConfig'
- type: 'null'
description: Configuration options for reasoning models.
stream:
anyOf:
- type: boolean
- type: 'null'
title: Stream
description: Whether to stream the generation result. When set to `true`, the response is sent as [server-sent events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events#event_stream_format) once generated.
default: false
model:
type: string
title: Model
description: Code of the model to use. See [available model list](https://friendli.ai/docs/guides/model-apis/pricing#billing-methods).
examples:
- zai-org/GLM-5.2
additionalProperties: true
type: object
required:
- input
- model
title: ServerlessResponsesBody
example:
input: Hello!
model: zai-org/GLM-5.2
ResponsesTextFormatText:
properties:
type:
type: string
const: text
title: Type
description: The type of response format being defined. Always `text`.
type: object
required:
- type
title: ResponsesTextFormatText
ResponsesContentBlock:
oneOf:
- $ref: '#/components/schemas/ResponsesInputText'
title: Input Text
- $ref: '#/components/schemas/ResponsesInputImage'
title: Input Image
- $ref: '#/components/schemas/ResponsesOutputText'
title: Output Text
- $ref: '#/components/schemas/ResponsesRefusal'
title: Refusal
discriminator:
propertyName: type
mapping:
input_image: '#/components/schemas/ResponsesInputImage'
input_text: '#/components/schemas/ResponsesInputText'
output_text: '#/components/schemas/ResponsesOutputText'
refusal: '#/components/schemas/ResponsesRefusal'
ResponsesReasoningSummaryText:
properties:
type:
type: string
const: summary_text
title: Type
description: The type of the object. Always `summary_text`.
text:
type: string
title: Text
description: A summary of the reasoning output from the model so far.
type: object
required:
- type
- text
title: ResponsesReasoningSummaryText
ResponsesStreamFunctionCallArgumentsDone:
properties:
type:
type: string
const: response.function_call_arguments.done
title: Type
description: The type of the event.
item_id:
type: string
title: Item Id
description: The ID of the output item.
output_index:
type: integer
title: Output Index
description: The index of the output item.
arguments:
type: string
title: Arguments
description: The function-call arguments.
name:
type: string
title: Name
description: The name of the function that was called.
sequence_number:
type: integer
title: Sequence Number
description: The sequence number for this event.
type: object
required:
- type
- item_id
- output_index
- arguments
- name
- sequence_number
title: ResponsesStreamFunctionCallArgumentsDone
ResponsesSuccess:
properties:
id:
type: string
title: Id
description: Unique identifier for this response.
object:
type: string
const: response
title: Object
description: The object type of this resource - always set to `response`.
created_at:
type: integer
title: Created At
description: Unix timestamp (in seconds) of when this response was created.
error:
anyOf:
- $ref: '#/components/schemas/ResponsesError'
- type: 'null'
description: An error object returned when the model fails to generate a Response.
status:
anyOf:
- type: string
enum:
- completed
- failed
- in_progress
- cancelled
- queued
- incomplete
- type: 'null'
title: Status
description: The status of the response generation. One of `completed`, `failed`, `in_progress`, `cancelled`, `queued`, or `incomplete`.
output:
items:
$ref: '#/components/schemas/ResponsesOutputItem'
type: array
title: Output
description: An array of content items generated by the model.
usage:
anyOf:
- $ref: '#/components/schemas/ResponsesUsage'
- type: 'null'
description: Represents token usage details including input tokens, output tokens, a breakdown of output tokens, and the total tokens used.
incomplete_details:
anyOf:
- $ref: '#/components/schemas/ResponsesIncompleteDetails'
- type: 'null'
description: Details about why the response is incomplete.
model:
anyOf:
- type: string
- type: 'null'
title: Model
description: Model ID used to generate the response.
additionalProperties: true
type: object
required:
- id
- object
- created_at
- output
title: ResponsesSuccess
ResponsesInputItem:
anyOf:
- $ref: '#/components/schemas/ResponsesInputMessage'
- $ref: '#/components/schemas/ResponsesFunctionCall'
- $ref: '#/components/schemas/ResponsesFunctionCallOutput'
- $ref: '#/components/schemas/ResponsesCustomToolCall'
- $ref: '#/components/schemas/ResponsesCustomToolCallOutput'
- $ref: '#/components/schemas/ResponsesReasoningItem'
title: ResponsesInputItem
ResponsesStreamOutputItemDone:
properties:
type:
type: string
const: response.output_item.done
title: Type
description: The type of the event.
output_index:
type: integer
title: Output Index
description: The index of the output item that was marked done.
item:
$ref: '#/components/schemas/ResponsesOutputItem'
description: The completed output item.
sequence_number:
type: integer
title: Sequence Number
description: The sequence number for this event.
type: object
required:
- type
- output_index
- item
- sequence_number
title: ResponsesStreamOutputItemDone
ResponsesStreamContentPartAdded:
properties:
type:
type: string
const: response.content_part.added
title: Type
description: The type of the event.
item_id:
type: string
title: Item Id
description: The ID of the output item the content part was added to.
output_index:
type: integer
title: Output Index
description: The index of the output item.
content_index:
type: integer
title: Content Index
description: The index of the content part within the output item.
part:
$ref: '#/components/schemas/ResponsesContentPart'
description: The content part that was added.
sequence_number:
type: integer
title: Sequence Number
description: The sequence number for this event.
type: object
required:
- type
- item_id
- output_index
- content_index
- part
- sequence_number
title: ResponsesStreamContentPartAdded
ResponsesCustomToolCallOutputContent:
oneOf:
- $ref: '#/components/schemas/ResponsesInputText'
title: Input Text
- $ref: '#/components/schemas/ResponsesInputImage'
title: Input Image
discriminator:
propertyName: type
mapping:
input_image: '#/components/schemas/ResponsesInputImage'
input_text: '#/components/schemas/ResponsesInputText'
ResponsesRefusal:
properties:
type:
type: string
const: refusal
title: Type
description: The type of the refusal. Always `refusal`.
refusal:
type: string
title: Refusal
description: The refusal explanation from the model.
type: object
required:
- type
- refusal
title: ResponsesRefusal
ServerlessResponsesSuccess:
properties:
id:
type: string
title: Id
description: Unique identifier for this response.
object:
type: string
const: response
title: Object
description: The object type of this resource - always set to `response`.
created_at:
type: integer
title: Created At
description: Unix timestamp (in seconds) of when this response was created.
error:
anyOf:
- $ref: '#/components/schemas/ResponsesError'
- type: 'null'
description: An error object returned when the model fails to generate a Response.
status:
anyOf:
- type: string
enum:
- completed
- failed
- in_progress
- cancelled
- queued
- incomplete
- type: 'null'
title: Status
description: The status of the response generation. One of `completed`, `failed`, `in_progress`, `cancelled`, `queued`, or `incomplete`.
output:
items:
$ref: '#/components/schemas/ResponsesOutputItem'
type: array
title: Output
description: An array of content items generated by the model.
usage:
anyOf:
- $ref: '#/components/schemas/ResponsesUsage'
- type: 'null'
description: Represents token usage details including input tokens, output tokens, a breakdown of output tokens, and the total tokens used.
incomplete_details:
anyOf:
- $ref: '#/components/schemas/ResponsesIncompleteDetails'
- type: 'null'
description: Details about why the response is incomplete.
model:
anyOf:
- type: string
- type: 'null'
title: Model
description: Model ID used to generate the response.
additionalProperties: true
type: object
required:
- id
- object
- created_at
- output
title: ServerlessResponsesSuccess
ResponsesCustomToolCall:
properties:
type:
type: string
const: custom_tool_call
title: Type
description: The type of the custom tool call. Always `custom_tool_call`.
call_id:
type: string
title: Call Id
description: An identifier used to map this custom tool call to a tool call output.
name:
type: string
title: Name
description: The name of the custom tool being called.
input:
type: string
title: Input
description: The input for the custom tool call generated by the model.
id:
anyOf:
- type: string
- type: 'null'
title: Id
description: The unique ID of the custom tool call.
type: object
required:
- type
- call_id
- name
- input
title: ResponsesCustomToo
# --- truncated at 32 KB (59 KB total) ---
# Full source: https://raw.githubusercontent.com/api-evangelist/friendliai/refs/heads/main/openapi/friendliai-serverless-responses-api-openapi.yml