def add_one(x: int) -> int:
    return x + 1
def mul_two(x: int) -> int:
    return x * 2
runnable_1 = RunnableLambda(add_one)
runnable_2 = RunnableLambda(mul_two)
sequence = runnable_1 | runnable_2
# Or equivalently:
# sequence = RunnableSequence(first=runnable_1, last=runnable_2)
sequence.invoke(1)
await runnable.ainvoke(1)
sequence.batch([1, 2, 3])
await sequence.abatch([1, 2, 3])
Here’s an example that uses streams JSON output generated by an LLM:
from langchain_core.output_parsers.json import SimpleJsonOutputParser
from langchain_core.chat_models.openai import ChatOpenAI
prompt = PromptTemplate.from_template(
    'In JSON format, give me a list of {topic} and their '
    'corresponding names in French, Spanish and in a '
    'Cat Language.'
)
model = ChatOpenAI()
chain = prompt | model | SimpleJsonOutputParser()
async for chunk in chain.astream({'topic': 'colors'}):
    print('-')
    print(chunk, sep='', flush=True)
Create a new model by parsing and validating input data from keyword arguments.
Raises ValidationError if the input data cannot be parsed to form a valid model.
param first: langchain_core.runnables.base.Runnable[langchain_core.runnables.utils.Input, Any] [Required]¶
The first runnable in the sequence.
param last: langchain_core.runnables.base.Runnable[Any, langchain_core.runnables.utils.Output] [Required]¶
The last runnable in the sequence.