InvokeWithLayerRequest
Both users and bots can use this method. See code examples.
---functions---
invokeWithLayer#da9b0d0d {X:Type} layer:int query:!X = XReturns
This function returns the result of whatever the result from invoking the request passed through query is.
Parameters
| layer | int | |
| query | !X | A different Request must be supplied for this argument. | 
Known RPC errors
This request can cause 13 known errors:
| AuthBytesInvalidError | The provided authorization is invalid. | 
| AuthKeyDuplicatedError | The authorization key (session file) was used under two different IP addresses simultaneously, and can no longer be used. Use the same session exclusively, or use different sessions. | 
| CdnMethodInvalidError | This method cannot be invoked on a CDN server. Refer to https://core.telegram.org/cdn#schema for available methods. | 
| ChatWriteForbiddenError | You can't write in this chat. | 
| ConnectionApiIdInvalidError | The provided API id is invalid. | 
| ConnectionDeviceModelEmptyError | Device model empty. | 
| ConnectionLangPackInvalidError | The specified language pack is not valid. This is meant to be used by official applications only so far, leave it empty. | 
| ConnectionNotInitedError | Connection not initialized. | 
| ConnectionSystemEmptyError | Connection system empty. | 
| InputLayerInvalidError | The provided layer is invalid. | 
| InviteHashExpiredError | The chat the user tried to join has expired and is not valid anymore. | 
| NeedMemberInvalidError | The provided member is invalid or does not exist (for example a thumb size). | 
| TimeoutError | A timeout occurred while fetching data from the worker. | 
You can import these from telethon.errors.
Example
from telethon.sync import TelegramClient
from telethon import functions, types
with TelegramClient(name, api_id, api_hash) as client:
    result = client(functions.InvokeWithLayerRequest(
        layer=42,
        query=other_request
    ))
    print(result.stringify())