Endpoint Response Snippet

The EndpointResponseSnippet component is used to reference an endpoint response from your API Reference. Below is an example of referencing the response for the POST /snippets endpoint.

Markdown
1<EndpointResponseSnippet endpoint='POST /snippets' />

will be rendered as

Response
1[
2 {
3 "type": "python",
4 "async_client": "import VellumAsync from vellum.client\nclient = VellumAsync(api_key=\"YOUR_API_KEY\")\nawait client.search(query=\"Find documents written in the last 5 days\")\n",
5 "sdk": {
6 "package": "vellum-ai",
7 "version": "1.2.1"
8 },
9 "sync_client": "import Vellum from vellum.client\nclient = Vellum(api_key=\"YOUR_API_KEY\")\nclient.search(query=\"Find documents written in the last 5 days\")\n"
10 },
11 {
12 "type": "typescript",
13 "client": "import { VellumClient } from \"vellum-ai\";\nconst vellum = VellumClient({\n apiKey=\"YOUR_API_KEY\"\n})\nvellum.search({\n query: \"Find documents written in the last 5 days\"\n})\n",
14 "sdk": {
15 "package": "vellum-ai",
16 "version": "1.2.1"
17 }
18 }
19]

Reference particular examples

If you want to reference a particular example in the response snippet, you can set example prop to the name of the example. See the steps below:

1

Define named examples

The highlighted lines show how to set the example name.

1paths:
2 /pet/{petId}:
3 put:
4 summary: Get a pet
5 operationId: pets_get
6 responses:
7 '200':
8 content:
9 application/json:
10 schema:
11 $ref: '#/components/schemas/Pet'
12 examples:
13 ExampleWithMarkley:
14 summary: This is an example of a Pet
15 value:
16 name: Markley
17 id: 44
1service:
2 auth: true
3 base-path: ""
4 endpoints:
5 update:
6 docs: Get a pet
7 method: GET
8 path: /pet/{petId}
9 response: Pet
10 examples:
11 - name: ExampleWithMarkley
12 docs: This is an example of a Pet
13 response:
14 body:
15 name: Markley
16 id: 44
2

Reference the example

In the API Definition, the example had a name ExampleWithMarkley. You can reference the example directly:

1 <EndpointResponseSnippet
2 endpoint="GET /pet/{petId}"
3 example="ExampleWithMarkley"
4 />