> For the complete documentation index, see [llms.txt](https://docs.pending.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.pending.ai/api-reference/pai-generator/sampling-structures.md).

# Sampling Structures

Speed up Hit Identification with rapid molecule sampling

Efficiently expand into chemical space by sampling from generative Deep-Learning models around an underlying distribution of molecules. With the ability to easily generate hundreds of thousands of unique structures in minutes, building a diverse library of molecular structures reduces the time and cost associated with traditional first Hit Identification methods - additionally see our other solutions to further improve Drug Discovery pipeline stages.

**Considerations:**

* A sample holds at most 500 molecules. For more, create a sample batch.
* Send `Prefer: respond-async` to get the sample back at once as `pending` (202), then poll `GET /samples/{sample_id}` for its molecules.
* Sampling speed is limited by API request rate limits and data transfer bottlenecks. For larger sampling requirements, contact us to discuss custom solutions.
* Structures are generated as unique SMILES within a single request, however duplicate structures may be generated across multiple requests. See individual model metadata for more information on uniqueness rates.

See [here](https://docs.pending.ai/capabilities/generative-ai) for more information on our **Generative AI** capability.

## Retrieve a sample

> Retrieves a sample and all generated structures. This is designed to allow retrieving any samples previously generated.

````json
{"openapi":"3.1.0","info":{"title":"PAI Generator","version":"v0.0.104"},"tags":[{"name":"Samples","description":"\nEfficiently expand into chemical space by sampling from generative Deep-Learning models\naround an underlying distribution of molecules. With the ability to easily generate\nhundreds of thousands of unique structures in minutes, building a diverse library of\nmolecular structures reduces the time and cost associated with traditional first\nHit Identification methods - additionally see our other solutions to further improve\nDrug Discovery pipeline stages.\n\n**Considerations:**\n\n- A sample holds at most 500 molecules. For more, create a sample batch.\n- Send `Prefer: respond-async` to get the sample back at once as `pending` (202), then\npoll `GET /samples/{sample_id}` for its molecules.\n- Sampling speed is limited by API request rate limits and data transfer bottlenecks.\nFor larger sampling requirements, contact us to discuss custom solutions.\n- Structures are generated as unique SMILES within a single request, however\nduplicate structures may be generated across multiple requests. See individual model\nmetadata for more information on uniqueness rates.\n\nSee [here](https://docs.pending.ai/capabilities/generative-ai)  for more information on\nour **Generative AI** capability.\n"}],"servers":[{"url":"https://api.pending.ai/generator/v1","description":"Pending AI API Server"}],"security":[{"oauth":[""]},{"token":[""]}],"components":{"securitySchemes":{"oauth":{"type":"oauth2","description":"OAuth2 authentication.\n\nAuthenticate using the Pending AI [authorization server](https://auth.pending.ai/authorize) through an implicit OAuth2 flow. You will be redirected to a Pending AI login page to authenticate and authorize access to your account. After authorization, you will be redirected back to the original application with an access token. Ensure that the application is registered with Pending AI and/or that the correct redirect URI is configured. Contact Pending AI support for more information if the application is not registered.","flows":{"implicit":{"scopes":{"openid":"Required for OpenID Connect sign-in","profile":"Access to the user's basic profile information","email":"Access to the user's email address","offline_access":"Request a refresh token","generator_api.models:create":"Create PAI Generator models","generator_api.models:read":"Read PAI Generator models","generator_api.models:update":"Update PAI Generator models","generator_api.models:delete":"Delete PAI Generator models","generator_api.samples:create":"Create PAI Generator samples","generator_api.samples:read":"Read PAI Generator samples","generator_api.samples:update":"Update PAI Generator samples","generator_api.samples:delete":"Delete PAI Generator samples"},"authorizationUrl":"https://auth.pending.ai/authorize"}}},"token":{"type":"http","description":"Bearer token authentication.\n\nProvide a valid Pending AI authentication token. Generating tokens can be done manually through the Pending AI CLI. Ensure you have an existing account or [register now](https://lab.pending.ai/).\n\n```bash\npendingai auth login\npendingai auth token\n```","scheme":"bearer","bearerFormat":"JWT"}},"schemas":{"SampleResource":{"properties":{"id":{"type":"string","pattern":"^\\w+$","title":"Resource Id","description":"The unique resource identifier."},"object":{"type":"string","pattern":"^\\w+$","title":"Resource Object","description":"The type of resource."},"model_id":{"anyOf":[{"type":"string","pattern":"^\\w+$"},{"type":"null"}],"title":"Model Id","description":"An `id` belonging to the model used to generate the sample. The\nvalue can be used to retrieve more information about the model.\n`None` only while a `SampleBatch` chunk is still `pending` and no\nmodel has been resolved for it yet."},"smiles":{"items":{"type":"string"},"type":"array","title":"Smiles","description":"A collection of generated SMILES structures from the model. The\nnumber of structures will correspond to the `num_samples` value\nprovided when creating the sample."},"status":{"type":"string","enum":["pending","processing","completed","failed"],"title":"Status","description":"The lifecycle status of the sample.","default":"completed"},"batch_id":{"anyOf":[{"type":"string","pattern":"^\\w+$"},{"type":"null"}],"title":"Batch Id","description":"The `id` of the `SampleBatch` this sample was created as a chunk of,\nif any. `None` for a sample created directly via `POST /samples`."},"error":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Error","description":"A short error message, set only when `status` is `failed`."},"created_at":{"type":"string","format":"date-time","title":"Created At","description":"Timestamp for when the sample was created."}},"type":"object","required":["id","object","smiles"],"title":"Sample","description":"A sample contains a collection of molecules generated by a machine-\nlearning model on a defined chemical space. Samples represent the\nnovel structures in a SMILES format."},"HTTPValidationError":{"properties":{"detail":{"items":{"$ref":"#/components/schemas/ValidationError"},"type":"array","title":"Detail"}},"type":"object","title":"HTTPValidationError"},"ValidationError":{"properties":{"loc":{"items":{"anyOf":[{"type":"string"},{"type":"integer"}]},"type":"array","title":"Location"},"type":{"type":"string","title":"Error Type"}},"type":"object","required":["loc","msg","type"],"title":"ValidationError"},"ResponseValidationError":{"properties":{"detail":{"items":{"$ref":"#/components/schemas/ValidationError"},"type":"array","title":"Detail"}},"type":"object","title":"ResponseValidationError"}}},"paths":{"/samples/{sample_id}":{"get":{"tags":["Samples"],"summary":"Retrieve a sample","description":"Retrieves a sample and all generated structures. This is designed to allow retrieving any samples previously generated.","operationId":"retrieve_sample_samples__sample_id__get","parameters":[{"description":"A unique identifier for a sample resource.","required":true,"schema":{"type":"string","maxLength":255,"minLength":1,"pattern":"^\\w+$","title":"Sample Id","description":"A unique identifier for a sample resource."},"name":"sample_id","in":"path"},{"description":"An optional header to be provided when accepting Base64 compressed response content. Providing a value containing `gzip` yields gzipped Base64-encoded content for the response body.","required":false,"schema":{"anyOf":[{"type":"string"},{"items":{"type":"string"},"type":"array"},{"type":"null"}],"title":"Accept-Encoding","description":"An optional header to be provided when accepting Base64 compressed response content. Providing a value containing `gzip` yields gzipped Base64-encoded content for the response body.","default":"*"},"name":"accept-encoding","in":"header"}],"responses":{"200":{"description":"Returns the sample.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SampleResource"}}}},"404":{"description":"Sample resource not found.","content":{"application/json":{"schema":{"type":"null","title":"Return"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}},"500":{"description":"Response Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ResponseValidationError"}}}}}}}}}
````

## List samples

> Retrieve a list of samples. Key-based pagination is supported. See query parameters for more details on how to retrieve the next or previous page of results.

````json
{"openapi":"3.1.0","info":{"title":"PAI Generator","version":"v0.0.104"},"tags":[{"name":"Samples","description":"\nEfficiently expand into chemical space by sampling from generative Deep-Learning models\naround an underlying distribution of molecules. With the ability to easily generate\nhundreds of thousands of unique structures in minutes, building a diverse library of\nmolecular structures reduces the time and cost associated with traditional first\nHit Identification methods - additionally see our other solutions to further improve\nDrug Discovery pipeline stages.\n\n**Considerations:**\n\n- A sample holds at most 500 molecules. For more, create a sample batch.\n- Send `Prefer: respond-async` to get the sample back at once as `pending` (202), then\npoll `GET /samples/{sample_id}` for its molecules.\n- Sampling speed is limited by API request rate limits and data transfer bottlenecks.\nFor larger sampling requirements, contact us to discuss custom solutions.\n- Structures are generated as unique SMILES within a single request, however\nduplicate structures may be generated across multiple requests. See individual model\nmetadata for more information on uniqueness rates.\n\nSee [here](https://docs.pending.ai/capabilities/generative-ai)  for more information on\nour **Generative AI** capability.\n"}],"servers":[{"url":"https://api.pending.ai/generator/v1","description":"Pending AI API Server"}],"security":[{"oauth":[""]},{"token":[""]}],"components":{"securitySchemes":{"oauth":{"type":"oauth2","description":"OAuth2 authentication.\n\nAuthenticate using the Pending AI [authorization server](https://auth.pending.ai/authorize) through an implicit OAuth2 flow. You will be redirected to a Pending AI login page to authenticate and authorize access to your account. After authorization, you will be redirected back to the original application with an access token. Ensure that the application is registered with Pending AI and/or that the correct redirect URI is configured. Contact Pending AI support for more information if the application is not registered.","flows":{"implicit":{"scopes":{"openid":"Required for OpenID Connect sign-in","profile":"Access to the user's basic profile information","email":"Access to the user's email address","offline_access":"Request a refresh token","generator_api.models:create":"Create PAI Generator models","generator_api.models:read":"Read PAI Generator models","generator_api.models:update":"Update PAI Generator models","generator_api.models:delete":"Delete PAI Generator models","generator_api.samples:create":"Create PAI Generator samples","generator_api.samples:read":"Read PAI Generator samples","generator_api.samples:update":"Update PAI Generator samples","generator_api.samples:delete":"Delete PAI Generator samples"},"authorizationUrl":"https://auth.pending.ai/authorize"}}},"token":{"type":"http","description":"Bearer token authentication.\n\nProvide a valid Pending AI authentication token. Generating tokens can be done manually through the Pending AI CLI. Ensure you have an existing account or [register now](https://lab.pending.ai/).\n\n```bash\npendingai auth login\npendingai auth token\n```","scheme":"bearer","bearerFormat":"JWT"}},"schemas":{"generator_api__models__resource__ResourceList_Sample__ListOutputItem_":{"properties":{"object":{"type":"string","pattern":"^\\w+$","title":"Resource Object","description":"The type of resource.","default":"list"},"data":{"items":{"$ref":"#/components/schemas/generator_api__models__samples__Sample__ListOutputItem"},"type":"array","title":"Data","description":"A list containing the retrieved objects. The list can contain fewer\nobjects than requested if a smaller number of results were found."},"has_more":{"type":"boolean","title":"Has More","description":"A boolean flag that indicates whether there are more items available\nto be fetched on subsequent pages. Used for pagination control."}},"type":"object","required":["data","has_more"],"title":"ResourceList[Sample.ListOutputItem]"},"generator_api__models__samples__Sample__ListOutputItem":{"properties":{"id":{"type":"string","pattern":"^\\w+$","title":"Resource Id","description":"The unique resource identifier."},"object":{"type":"string","pattern":"^\\w+$","title":"Resource Object","description":"The type of resource."},"model_id":{"anyOf":[{"type":"string","pattern":"^\\w+$"},{"type":"null"}],"title":"Model Id","description":"An `id` belonging to the model used to generate the sample. The\nvalue can be used to retrieve more information about the model."},"num_smiles":{"type":"integer","minimum":0,"title":"Num Smiles","description":"The number of sampled molecules generated for the request. `0`\nfor a `SampleBatch` chunk that hasn't completed yet."},"status":{"type":"string","enum":["pending","processing","completed","failed"],"title":"Status","description":"The lifecycle status of the sample.","default":"completed"},"batch_id":{"anyOf":[{"type":"string","pattern":"^\\w+$"},{"type":"null"}],"title":"Batch Id","description":"The `id` of the `SampleBatch` this sample was created as a chunk\nof, if any."},"created_at":{"type":"string","format":"date-time","title":"Created At","description":"Timestamp for when the sample was created."}},"type":"object","required":["id","object","num_smiles"],"title":"Sample","description":"A reduced representation of a sample for providing metadata to\nallow for efficient listing. To retrieve sample results, request\nindividual samples by their `id`."},"HTTPValidationError":{"properties":{"detail":{"items":{"$ref":"#/components/schemas/ValidationError"},"type":"array","title":"Detail"}},"type":"object","title":"HTTPValidationError"},"ValidationError":{"properties":{"loc":{"items":{"anyOf":[{"type":"string"},{"type":"integer"}]},"type":"array","title":"Location"},"type":{"type":"string","title":"Error Type"}},"type":"object","required":["loc","msg","type"],"title":"ValidationError"},"ResponseValidationError":{"properties":{"detail":{"items":{"$ref":"#/components/schemas/ValidationError"},"type":"array","title":"Detail"}},"type":"object","title":"ResponseValidationError"}}},"paths":{"/samples":{"get":{"tags":["Samples"],"summary":"List samples","description":"Retrieve a list of samples. Key-based pagination is supported. See query parameters for more details on how to retrieve the next or previous page of results.","operationId":"list_samples_samples_get","parameters":[{"description":"Limit the number of resources returned within the `data` field of the paged response. The field may contain fewer items than the specified limit when there are not enough items to return.","required":false,"schema":{"type":"integer","maximum":100,"minimum":1,"title":"Limit","description":"Limit the number of resources returned within the `data` field of the paged response. The field may contain fewer items than the specified limit when there are not enough items to return.","default":5},"name":"limit","in":"query"},{"description":"A key used to navigate pagination results. The given value must match an `id` for the specific resource `object` type. If provided, the paged response will contain resources from the next 'page', or those that were submitted before the matched resource (reverse chronological order).","required":false,"schema":{"anyOf":[{"type":"string","maxLength":255,"minLength":1,"pattern":"^\\w+$"},{"type":"null"}],"title":"Next-Page","description":"A key used to navigate pagination results. The given value must match an `id` for the specific resource `object` type. If provided, the paged response will contain resources from the next 'page', or those that were submitted before the matched resource (reverse chronological order)."},"name":"next-page","in":"query"},{"description":"A key used to navigate pagination results. The given value must match an `id` for the specific resource `object` type. If provided, the paged response will contain resources from the previous 'page', or those that were submitted after the matched resource (reverse chronological order).","required":false,"schema":{"anyOf":[{"type":"string","maxLength":255,"minLength":1,"pattern":"^\\w+$"},{"type":"null"}],"title":"Prev-Page","description":"A key used to navigate pagination results. The given value must match an `id` for the specific resource `object` type. If provided, the paged response will contain resources from the previous 'page', or those that were submitted after the matched resource (reverse chronological order)."},"name":"prev-page","in":"query"}],"responses":{"200":{"description":"Returns a list of samples.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/generator_api__models__resource__ResourceList_Sample__ListOutputItem_"}}}},"400":{"description":"Request contained invalid data.","content":{"application/json":{"schema":{"type":"null","title":"Return"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}},"500":{"description":"Response Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ResponseValidationError"}}}}}}}}}
````

## Create a sample

> Create a sample by generating molecules from a specific model. When no model is provided, any will be used that is readily available. With \`Prefer: respond-async\` it returns at once with the sample \`pending\` (202); poll \`GET /samples/{sample\_id}\` for its molecules.

````json
{"openapi":"3.1.0","info":{"title":"PAI Generator","version":"v0.0.104"},"tags":[{"name":"Samples","description":"\nEfficiently expand into chemical space by sampling from generative Deep-Learning models\naround an underlying distribution of molecules. With the ability to easily generate\nhundreds of thousands of unique structures in minutes, building a diverse library of\nmolecular structures reduces the time and cost associated with traditional first\nHit Identification methods - additionally see our other solutions to further improve\nDrug Discovery pipeline stages.\n\n**Considerations:**\n\n- A sample holds at most 500 molecules. For more, create a sample batch.\n- Send `Prefer: respond-async` to get the sample back at once as `pending` (202), then\npoll `GET /samples/{sample_id}` for its molecules.\n- Sampling speed is limited by API request rate limits and data transfer bottlenecks.\nFor larger sampling requirements, contact us to discuss custom solutions.\n- Structures are generated as unique SMILES within a single request, however\nduplicate structures may be generated across multiple requests. See individual model\nmetadata for more information on uniqueness rates.\n\nSee [here](https://docs.pending.ai/capabilities/generative-ai)  for more information on\nour **Generative AI** capability.\n"}],"servers":[{"url":"https://api.pending.ai/generator/v1","description":"Pending AI API Server"}],"security":[{"oauth":[""]},{"token":[""]}],"components":{"securitySchemes":{"oauth":{"type":"oauth2","description":"OAuth2 authentication.\n\nAuthenticate using the Pending AI [authorization server](https://auth.pending.ai/authorize) through an implicit OAuth2 flow. You will be redirected to a Pending AI login page to authenticate and authorize access to your account. After authorization, you will be redirected back to the original application with an access token. Ensure that the application is registered with Pending AI and/or that the correct redirect URI is configured. Contact Pending AI support for more information if the application is not registered.","flows":{"implicit":{"scopes":{"openid":"Required for OpenID Connect sign-in","profile":"Access to the user's basic profile information","email":"Access to the user's email address","offline_access":"Request a refresh token","generator_api.models:create":"Create PAI Generator models","generator_api.models:read":"Read PAI Generator models","generator_api.models:update":"Update PAI Generator models","generator_api.models:delete":"Delete PAI Generator models","generator_api.samples:create":"Create PAI Generator samples","generator_api.samples:read":"Read PAI Generator samples","generator_api.samples:update":"Update PAI Generator samples","generator_api.samples:delete":"Delete PAI Generator samples"},"authorizationUrl":"https://auth.pending.ai/authorize"}}},"token":{"type":"http","description":"Bearer token authentication.\n\nProvide a valid Pending AI authentication token. Generating tokens can be done manually through the Pending AI CLI. Ensure you have an existing account or [register now](https://lab.pending.ai/).\n\n```bash\npendingai auth login\npendingai auth token\n```","scheme":"bearer","bearerFormat":"JWT"}},"schemas":{"generator_api__models__samples__Sample__CreateParams":{"properties":{"model_id":{"anyOf":[{"type":"string","pattern":"^\\w+$"},{"type":"null"}],"title":"Model Id","description":"Optional `id` belonging to a model to use for generating the\nsample. If no model is provided, any will be used that is\nreadily available."},"size":{"type":"integer","maximum":500,"minimum":1,"title":"Size","description":"The number of sampled molecules to generate for the request, at\nmost 500. For more, create a sample batch (`POST /sample-batches`)."}},"type":"object","required":["size"],"title":"SampleCreateParams","description":"Request data for creating a new sample."},"SampleResource":{"properties":{"id":{"type":"string","pattern":"^\\w+$","title":"Resource Id","description":"The unique resource identifier."},"object":{"type":"string","pattern":"^\\w+$","title":"Resource Object","description":"The type of resource."},"model_id":{"anyOf":[{"type":"string","pattern":"^\\w+$"},{"type":"null"}],"title":"Model Id","description":"An `id` belonging to the model used to generate the sample. The\nvalue can be used to retrieve more information about the model.\n`None` only while a `SampleBatch` chunk is still `pending` and no\nmodel has been resolved for it yet."},"smiles":{"items":{"type":"string"},"type":"array","title":"Smiles","description":"A collection of generated SMILES structures from the model. The\nnumber of structures will correspond to the `num_samples` value\nprovided when creating the sample."},"status":{"type":"string","enum":["pending","processing","completed","failed"],"title":"Status","description":"The lifecycle status of the sample.","default":"completed"},"batch_id":{"anyOf":[{"type":"string","pattern":"^\\w+$"},{"type":"null"}],"title":"Batch Id","description":"The `id` of the `SampleBatch` this sample was created as a chunk of,\nif any. `None` for a sample created directly via `POST /samples`."},"error":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Error","description":"A short error message, set only when `status` is `failed`."},"created_at":{"type":"string","format":"date-time","title":"Created At","description":"Timestamp for when the sample was created."}},"type":"object","required":["id","object","smiles"],"title":"Sample","description":"A sample contains a collection of molecules generated by a machine-\nlearning model on a defined chemical space. Samples represent the\nnovel structures in a SMILES format."},"HTTPValidationError":{"properties":{"detail":{"items":{"$ref":"#/components/schemas/ValidationError"},"type":"array","title":"Detail"}},"type":"object","title":"HTTPValidationError"},"ValidationError":{"properties":{"loc":{"items":{"anyOf":[{"type":"string"},{"type":"integer"}]},"type":"array","title":"Location"},"type":{"type":"string","title":"Error Type"}},"type":"object","required":["loc","msg","type"],"title":"ValidationError"},"ResponseValidationError":{"properties":{"detail":{"items":{"$ref":"#/components/schemas/ValidationError"},"type":"array","title":"Detail"}},"type":"object","title":"ResponseValidationError"}}},"paths":{"/samples":{"post":{"tags":["Samples"],"summary":"Create a sample","description":"Create a sample by generating molecules from a specific model. When no model is provided, any will be used that is readily available. With `Prefer: respond-async` it returns at once with the sample `pending` (202); poll `GET /samples/{sample_id}` for its molecules.","operationId":"create_sample_samples_post","parameters":[{"description":"An optional header to be provided when accepting Base64 compressed response content. Providing a value containing `gzip` yields gzipped Base64-encoded content for the response body.","required":false,"schema":{"anyOf":[{"type":"string"},{"items":{"type":"string"},"type":"array"},{"type":"null"}],"title":"Accept-Encoding","description":"An optional header to be provided when accepting Base64 compressed response content. Providing a value containing `gzip` yields gzipped Base64-encoded content for the response body.","default":"*"},"name":"accept-encoding","in":"header"},{"description":"`respond-async` returns the sample at once with status `pending` (HTTP 202); poll `GET /samples/{sample_id}` until it is `completed` or `failed`. Without it the request waits for the molecules, as it always has.","required":false,"schema":{"anyOf":[{"type":"string"},{"items":{"type":"string"},"type":"array"},{"type":"null"}],"title":"Prefer","description":"`respond-async` returns the sample at once with status `pending` (HTTP 202); poll `GET /samples/{sample_id}` until it is `completed` or `failed`. Without it the request waits for the molecules, as it always has."},"name":"prefer","in":"header"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/generator_api__models__samples__Sample__CreateParams"}}},"required":true},"responses":{"200":{"description":"Returns the sample.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SampleResource"}}}},"202":{"description":"With `Prefer: respond-async`: the sample, `pending`.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SampleResource"}}}},"400":{"description":"Request contained invalid data.","content":{"application/json":{"schema":{"type":"null","title":"Return"}}}},"402":{"description":"The team has no plan, or can't generate that many molecules this billing period.","content":{"application/json":{"schema":{"type":"null","title":"Return"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}},"500":{"description":"Response Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ResponseValidationError"}}}}}}}}}
````
